수다닷컴

  • 해외여행
    • 괌
    • 태국
    • 유럽
    • 일본
    • 필리핀
    • 미국
    • 중국
    • 기타여행
    • 싱가폴
  • 건강
    • 다이어트
    • 당뇨
    • 헬스
    • 건강음식
    • 건강기타
  • 컴퓨터
    • 프로그램 개발일반
    • C언어
    • 비주얼베이직
  • 결혼생활
    • 출산/육아
    • 결혼준비
    • 엄마이야기방
  • 일상생활
    • 면접
    • 취업
    • 진로선택
  • 교육
    • 교육일반
    • 아이교육
    • 토익
    • 해외연수
    • 영어
  • 취미생활
    • 음악
    • 자전거
    • 수영
    • 바이크
    • 축구
  • 기타
    • 강아지
    • 제주도여행
    • 국내여행
    • 기타일상
    • 애플
    • 휴대폰관련
  • 프로그램 개발일반
  • C언어
  • 비주얼베이직

연결리스트 소스가 비주얼C에선 잘되고 터보c에선 안됩니다 ㅠ

달달한캔디

2023.04.01


질문 제목 : 연결리스트 소스가 어떤컴퓨터에선 잘되고 어떤 컴퓨터에선 안되는데 왜그러는건지좀 알려주세요.. ㅠ질문 요약 :컴퓨터도 다르고 저는 비주얼 6.0 c++으로햇고 교수님 컴퓨터에서는 터보c++ 으로했는데 0입력하면 잘 정지 되는데 교수님 컴퓨터에서는 안되요...질문 내용 :
소스는
#includestdio.h
#includestdlib.htypedef struct listnode{
long data;
struct listnode *link;
}listnode;typedef struct listheader{
listnode *head;
listnode *tail;
int length;
}listheader;void init(listheader *plist)
{ plist-head = plist-tail = null;
plist-length = 0;
}void insert_node(listheader *plist, long data)
{listnode *temp = (listnode *)malloc(sizeof(listnode));
if(temp == null)
exit(1);
temp-data = data;
temp-link = null;
listnode *p;
listnode *q;if (plist-tail == null)
{
plist-head = plist-tail = temp;
(plist-length)++;
}
else
{p = plist-head;while(1)
{
if(temp-data p-data)
{
if(p-link==null)
{
p-link = temp;
temp-link = null;
plist-tail = temp;
(plist-length)++;
break;
}
else
{
q = p;
p = p-link;
}
}

else
{
if(temp-data plist-head-data)
{
temp-link = plist-head;
plist-head = temp;
(plist-length)++;
break;
}
else
{
q-link = temp;
temp-link = p;
(plist-length)++;
break;
}
}
}
}
}
void remove_node(listheader *plist, long lo)
{int i=1;
listnode *re, *lre;
re = plist-head;while(1)
{
if(plist-head-data == lo)
{
plist-head = plist-head-link;
free(re);
(plist-length)--;
break;
}
else
{lre = re;
re = re-link;
i++;}

if(re == null)
{printf(그런 데이터가 존재하지 않습니다.\n);
break;
}
if(re-data == lo)
{
lre-link = re-link;
free(re);
(plist-length)--;
break;
}
else
{
lre = re;
re = re-link;
i++;
}}
}
void reverse_node(listheader *plist)
{
listnode *p, *q, *r;
if(plist-length == 3)
{plist-tail-link = plist-head-link;
plist-head-link = null;
plist-tail-link-link = plist-head;
plist-head = plist-tail;
plist-tail = plist-head-link-link;
}
else if(plist-length == 2)
{plist-head-link = null;
plist-tail-link = plist-head;
plist-head = plist-tail;
plist-tail = plist-head-link;
}
else
{
p = plist-head-link;
q = p-link;
&r = q-link;
p-link = plist-head;
plist-head-link = null;
while(1)
{q-link = p;
p = r-link;
r-link = q;
if(p == null)
{plist-tail = plist-head;
plist-head = r;
break;}
q = p-link;
if(q == null)
{
p-link = r;
plist-tail = plist-head;
plist-head = p;
break;
}
p-link = r;
r = q-link;
if(r == null)
{q-link = p;
plist-tail = plist-head;
plist-head = q;
break;
}
}
}
}
void print_data(listheader *plist)
{
listnode *t;
t = plist-head;
while(t != null)
{
printf(출력 값 : %d\n,t-data);
t = t-link;
}
printf(총 노드 수 : %d\n, plist-length);
}
void main()
{
int con;
long a, d;
listheader list1;
init(&list1);
printf(list1에 들어갈 값을 입력 하세요(0입력시 종료)\n);
while(1)
{
scanf(%d,&a);
if(a==0)
break;
insert_node(&list1, a);
}
while(1)
{printf(옵션 1. 출력 / 2. 뒤집기 / 3. 삭제 / 4. 프로그램 종료 \n);
scanf(%d,&con);
if(con == 1)
{printf(list1출력\n);
print_data(&list1);
}
else if(con == 2)
{reverse_node(&list1);
printf(\nlist1 뒤집기완료\n);}
else if(con == 3)
{printf(\n 삭제할 데이터를 입력하세요\n);
scanf(%d,&d);remove_node(&list1, d);
}
else if(con == 4)
exit(1);
else
printf(그런 옵션 없습니다.);
}
}입니다.왜 그런지좀알려주세요.. ㅠㅠ 제꺼는 0입력하면 잘종료되는데 교수님컴퓨터에서는 안되네요... ㅠㅠ

신청하기





COMMENT

댓글을 입력해주세요. 비속어와 욕설은 삼가해주세요.

번호 제 목 글쓴이 날짜
2700041 초보인데요 ㅎ 배열안에 배열을 집어넣을수 있나요?? 헛장사 2025-07-01
2700012 배열// (1) 전갈자리 2025-07-01
2699895 무한루프에 빠집니다.!! 해결좀부탁드려요 (10) 선아 2025-06-30
2699842 질문을 너무 많이 하네여.....죄송.... (2) 해님꽃 2025-06-29
2699816 오류 질문입니다.. (1) 해비치 2025-06-29
2699763 질문입니다 ! 꼭 좀 도와주세요ㅠㅠ (2) 미라 2025-06-28
2699555 c언어 다항식을 입력을 했는데 왜 출력이 안될까요? 피스케스 2025-06-27
2699528 C언어 포인터연산 질문입니다. (3) 안녕나야 2025-06-26
2699476 끌어올림;;달력 짜봤는데요 이 소스 줄일 수 있나요? - 스샷첨부 (2) 클라우드 2025-06-26
2699444 [좀 급함] system("explorer [주소] ") 문에 변수를 사용할 수 있나요? 알 2025-06-26
2699415 파일//read//와 배열 아란 2025-06-25
2699386 구조체 안에 일부분만 char 배열에 복사하려면 어떻게 해야하나요? (1) 미즈 2025-06-25
2699361 연결리스트 정렬하는 부분에 대해서 질문 드립니다 아이처럼 2025-06-25
2699304 [기초]아직 안주무시는분 계신가요..?포인터배열? 좀 도와주세요. 놀리기 2025-06-24
2699272 printf() 함수이용해서 프로그램 만들기 질문요! (5) 다가 2025-06-24
2699221 PUSH와 POP코드를 더 간단하게 어떻게 해야할까요? 파라미 2025-06-24
2699192 설치오류가 자꾸 나요 한번봐주세여~ (1) 소녀틳향기 2025-06-23
2699161 for loop안에 있는 if문 (9) Orange 2025-06-23
2699105 링크더리스트 이전 링크값 출력함수. 꼬꼬마 2025-06-23
2699078 정수를 한자리씩 배열에 담는 법은 어떻게 하나요.. (4) 귀염포텐 2025-06-22
<<  이전  1 2 3 4 5 6 7 8 9 10  다음  >>

수다닷컴 | 여러분과 함께하는 수다토크 커뮤니티 수다닷컴에 오신것을 환영합니다.
사업자등록번호 : 117-07-92748 상호 : 진달래여행사 대표자 : 명현재 서울시 강서구 방화동 890번지 푸르지오 107동 306호
copyright 2011 게시글 삭제 및 기타 문의 : clairacademy@naver.com