#include "stdafx.h"

#include <stdio.h> 

#include <stdlib.h> 

#include <iostream> 

using namespace std;



const int N = 12;//제가 임의의 수 지정한거



struct list { int data; list* next; };


list* cons_many(list* l, int n)

{

    list* p = l;


    srand(314); // 이것도 그냥 적당한 시드값 고정한거


    for (int i = 0; i < n; ++i)

    {

        p = new list( { rand() % 10, p } );

}


return p;

}


int main(void)

{

    list* l1 = cons_many(NULL, N); 

    for (list* p = l1; p != NULL; p = p->next)

    {

        cout << p->data << " ";

    }

    cout << endl << endl;


    list* l2 = NULL;

    ////////////////////////////////////////////

    //

    // 여기가 질문입니다 ㅠㅠㅠㅠ 어떻게 프로그램을 짜야할까요

    //

    ////////////////////////////////////////////


    for (list* p = l2; p != NULL; p = p->next)

    {

        cout << p->data << " ";

    }

    cout << endl << endl;


    return 0;

}


















과제는 프로그램을 짠거에서 '주어진 정수 리스트의 순서를 거꾸로 뒤집은 리스트 만들기'입니다.

제가 한 2시간 서핑해봤는데 전부 제가 배워보지 않은 방식으로 순서뒤집기를 하고 계시더라구요.

예를 들어서 

#include <iostream>

using namespace std;

void reverseArray(int *y, int c)

{

int temp=0;

int j=0;

int c2=c/2;

do

}

temp=y[j];

y[j]=y[c-1];

y[c-1]=temp;

j++;

c--;

}

while(j<c2);

}

main()

{

int x[]={1,10,100,5,4};

reverseArray(x,5);

for(int i=0;i<5;i++) cout << x[i]<<' ';

}

뭐 대충 이런식으루요. 

이런 방식으로 뒤집으라는걸 요구하는건진 모르겠습니다.

c언어 빡대가리라 정말 잘 모르겠습니다.

도움을 주시면 그 코드에 대해서 연구 해보겠습니다.