연결리스트 소스좀봐주세요..
후회중
질문 제목 : 자료구조 알파벳 ..연결리스트출력문 정리좀 해주세요질문 내용 :
문자열을 받아서 a - b - c 이렇게 나오도록 하는 소스인데요, 삽입삭제가능하게 하는건데
처음에 12345중에 하나를 누르잖아요
만약에 1을 눌렀으면 문자열 입력 이렇게 뜨고 또 어떤 문자열을입력할 수 있게 되잖아요
근데 어떤문자열을 입력할거니?이게 아니라 어떤번호를 누를거니? 또 이렇게나와요..ㅠㅠ
근데 여기서 a를 누르면 문자열이 들어가긴들어가는데
출력문이나 메인에서 문제가있는거같은데
도무지모르겠네요
제발 도와주세요..
#include stdio.h #include stdlib.h
struct node *head;
struct node{int num;char data;struct node *link;};
struct node *insert(struct node *pre, char data1){struct node *i;i=(struct node*)malloc(sizeof(struct node));i-data=data1;if(head==null){head=i;i-link=null;}else{i-link=pre-link;pre-link=i;}return (i);}
struct node printlist(){struct node *pt, *pt1;char character;printf(%c , head-data);pt=head;while(pt-link!=null){pt1=pt-link;pt=pt1;printf(- %c , pt-data);}printf(\n\n);}void listdelete(){struct node *f, *m, *r;int i;printf(what do you want to delete? : );scanf(%d, &i);printf(\n);f=m=head;m=m-link;do{if(f-data==i){m=f-link;head=m;free(f);break;}else if(m-data==i){r=m-link;f-link=m-link;free(m);break;}f=f-link;m=m-link;}while(1);}
void main(){int num;char character;struct node *pre;head=pre=null;do{printf(1. input character \n);//printf(2. input between numbers \n);printf(3. print character in list \n);printf(4. delete character \n);printf(5. exit \n);printf(\n\nselect number : );scanf(%d, &num);{if(num==1){printf(what do you want character? : );scanf(%c, &character);pre=insert(pre, character);printf(\n);}/*else if(num==2){if(head==null){printf(not exist number in space \n\n);}else{betweenlist();}}*/else if(num==3){if(head==null){printf(not exist number in space \n\n);}else{printlist();}}else if(num==4){if(head==null)printf(not exist number in space \n\n);elselistdelete();}/* else (num==5);{return 0;}*/} } while(num!=5);}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2700562 | 함수포인터에서요 (7) | 소심한여자 | 2025-07-06 |
2700530 | 전처리문 질문입니다. (1) | 아놀드 | 2025-07-05 |
2700510 | c언어를 어케하면 잘할수 있을까요.. | 연연두 | 2025-07-05 |
2700484 | 두 개가 차이가 뭔지 알려주세요...(소수 찾는 프로그램) (2) | 날위해 | 2025-07-05 |
2700426 | 인터넷 창 띄우는 질문이요 (1) | 정훈 | 2025-07-04 |
2700400 | 원넓이를 계산이요 ㅜㅜ | 천칭자리 | 2025-07-04 |
2700368 | if에 관해서 질문이요... | Orange | 2025-07-04 |
2700339 | 이거 결과값이 왜이런건지.. (4) | 그댸와나 | 2025-07-04 |
2700313 | 파일 읽어서 저장하는데 빈파일일 경우 문재가 발생하네요.. (2) | 크나 | 2025-07-03 |
2700287 | 구조체 동적할당 연습을 하는데 오류가 뜹니다...(해결) (3) | 아련나래 | 2025-07-03 |
2700264 | 문자와 숫자 동시에 입력??? | 글고운 | 2025-07-03 |
2700236 | txt파일로만 쓰고 읽게 하려면 어떻게 해야 하나요..?? (8) | 미국녀 | 2025-07-03 |
2700211 | 전위 연산자 (2) | 어른처럼 | 2025-07-02 |
2700183 | C에서 파일이름을 받고, 그 파일의 사이즈를 출력해줘야하는데 내용이 출력이 안되네요 ;ㅅ; | 피스케스 | 2025-07-02 |
2700150 | 꼭좀 도와주세요ㅠㅠㅠ | 호습다 | 2025-07-02 |
2700095 | 연산문제...질문... | 오빤테앵겨 | 2025-07-01 |
2700070 | while문 , 3의배수 출력하는 프로그램좀 짜주세욤. | 횃불 | 2025-07-01 |
2700041 | 초보인데요 ㅎ 배열안에 배열을 집어넣을수 있나요?? | 헛장사 | 2025-07-01 |
2700012 | 배열// (1) | 전갈자리 | 2025-07-01 |
2699895 | 무한루프에 빠집니다.!! 해결좀부탁드려요 (10) | 선아 | 2025-06-30 |