<div>typedef struct days{<br> int year, month, day;<br> char content[100000];<br> struct days *next;<br>}dates;</div> <div>dates *sc_head;<br>dates *sc_tail;</div> <div> </div> <div> </div> <div> </div> <div>이렇게 구조체를 불러 와 주고.</div> <div> </div> <div>year, month, day content 각각에 연도, 달, 날짜, 일정 을 입력을 받습니다. (여러개도 받지요 링크드리스트를 이용해서요)</div> <div> </div> <div>그리고 나서</div> <div> </div> <div>날짜가 오래된것일수록 </div> <div>ex 1년 1월 3일과 1년 1월 1일의 내용이 입력이 되면 그대로 출력할시 3일->1일 순서로 출력이 되지만 1일->3일 순서로</div> <div>앞으로 오게 순서를 아예 바꾸고 싶습니다. dates *array 를 불러와서 정렬된 순서대로 array에 집어넣는게 아닌, 마지막으로 데이터가 저장될</div> <div>sc_head에 정렬된 순서대로 저장내용이 바뀌게끔.</div> <div> </div> <div>하고싶은데 도저히 모르겠어요 ㅠ.ㅠ</div> <div> </div> <div>year month day info를 각각 입력받아서 (info는 %s로 문자열, 나머지는 int형) sc_head에 저장하는 함수는 밑에 있는거구요.</div> <div> </div> <div>void add_sch(int year, int month, int day, char* info)<br>{<br> dates *t;<br> dates *s;<br> t=(dates*)malloc(sizeof(dates));<br> t->year =year;<br> t->month = month;<br> t->day = day;<br> strcpy(t->content,info);<br> </div> <div> if(sc_head->next == sc_tail)<br> {<br> sc_head->next = t;<br> t->next = sc_tail;<br> }<br> else<br> {<br> s=sc_head;<br> while(s->next !=sc_tail)<br> {<br> s=s->next;<br> }<br> s->next=t;<br> t->next = sc_tail;<br> }<br>}</div> <div> </div> <div>저장작업이 완료된 후에 정렬하는 함수를 하나 만들어서 정렬이 되게끔 하고싶은데...</div> <div>하나하나 차근차근 해보려고 일단 일수부터 적은숫자가 앞으로 오게 정렬을 해보려고 했는데...</div> <div> </div> <div>void line_upday()<br>{<br> <br> <br> dates *t;<br> dates *p;<br> dates *s;<br> p=sc_head;<br> t = sc_head->next;<br> if(sc_head->next == sc_tail)<br> { <br> }<br> else<br> {<br> for(p = sc_head; p->next != sc_tail ;p=p->next)<br> {<br> for(t=sc_head->next; t->next != sc_tail ; t=t->next)<br> {<br> if(p->day > t->day)<br> {<br> s=p;<br> p=t;<br> t=s;<br> sc_head=p;<br> t->next=t;<br> sc_head->next=sc_head;<br> }<br> } <br> }<br> }</div> <div>}</div> <div> </div> <div>이런식으로 함수를 설정해봣더니 이 정렬하는 함수로 넘어와서 프로그램이 더이상 실행이 안되네요;;; 뭔가 안에서 무한for문이 도는거 같기도 하고;;</div> <div> </div> <div>도와주세요 ㅠ.ㅠ</div>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.