|
http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=33244 [복사]
제가 현재 짜고 있는 코드입니다 여기보면 goto main(1); 을 넣어놨는데
goto 말고 다른거 쓸수 있나요? 또 디버깅을하니 안되서 이코드에 버그가 있는지 확인해주셨으면 합니다.
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>
double main()
{
double select;
printf("DOS version : 0.12/1 Alpha\n");
printf("DOS\n");
cin>>select;
if(select==1)
{
printf("\n1:명령어 노드 \n");
printf("2:사칙연산 \n");
printf("3:ipconfig \n");
printf("4:chkdsk \n");
printf("5:date \n");
printf("6:time \n");
printf("If you want to goto main. select 1!\n");
printf("1. goto main 2. end\n");
cin>>select;
if(select==1)
{
goto main(1);
}
else if(select==2)
{
printf("exiting...");
return 0;
}
}
else if(select==2)
{
double select,a,b;
cout<<"계산기\n"<<endl;
cout<<"원하는계산을 선택하시오. 소숫점은 입력하지 마시오.\n"<<endl;
cout<<"1. 덧셈 2. 뺄셈 3. 곱셈 4. 나눗셈 \n"<<endl;
cin>>select;
if(select==1)
{
cout<<"덧셈할 두 숫자를 쓰시오.\n"<<endl;
cin>>a>>b;
cout<<a<<" + "<<b<<" = "<<a+b<<" \n"<<endl;
printf("If you want to goto main. select 1!\n");
printf("1. goto main 2. end\n");
cin>>select;
if(select==1)
{
goto main(1);
}
else if(select==2)
{
printf("exiting...");
return 0;
}
}
else if(select==2)
{
cout<<"뺄셈할 두 숫자를 쓰시오.\n"<<endl;
cin>>a>>b;
cout<<a<<" - "<<b<<" = "<<a-b<<" \n"<<endl;
printf("If you want to goto main. select 1!\n");
printf("1. goto main 2. end\n");
cin>>select;
if(select==1)
{
goto main(1);
}
else if(select==2)
{
printf("exiting...");
return 0;
}
}
else if(select==3)
{
cout<<"곱셈할 두 숫자를 쓰시오.\n"<<endl;
cin>>a>>b;
cout<<a<<" * "<<b<<" = "<<a*b<<" \n"<<endl;
printf("If you want to goto main. select 1!\n");
printf("1. goto main 2. end\n");
cin>>select;
if(select==1)
{
goto main(1);
}
else if(select==2)
{
printf("exiting...");
return 0;
}
}
else if(select==4)
{
cout<<"나눗셈할 두 숫자를 쓰시오. 0으로는 못 나눔니다.\n"<<endl;
cin>>a>>b;
if(b==0)
{
cout<<"0으로는 나눌 수 없습니다.\n"<<endl;
printf("If you want to goto main. select 1!\n");
printf("1. goto main 2. end\n");
cin>>select;
if(select==1)
{
goto main(1);
}
else if(select==2)
{
printf("exiting...");
return 0;
}
}
cout<<a<<" / "<<b<<" = "<<a/b<<" \n"<<endl;
printf("If you want to goto main. select 1!\n");
printf("1. goto main 2. end\n");
cin>>select;
if(select==1)
{
goto main(1);
}
else if(select==2)
{
printf("exiting...");
return 0;
}
}
else
{
cout<<"올바른 숫자를 입력하시오.\n"<<endl;
printf("If you want to goto main. select 1!\n");
printf("1. goto main 2. end\n");
cin>>select;
if(select==1)
{
goto main(1);
}
else if(select==2)
{
printf("exiting...");
return 0;
}
}
return 0;
}
else if(select==3)
{
system( "ipconfig" );
printf("If you want to goto main. select 1!\n");
printf("1. goto main 2. end\n");
cin>>select;
if(select==1)
{
goto main(1);
}
else if(select==2)
{
printf("exiting...");
return 0;
}
}
else if(select==4)
{
system( "chkdsk" );
printf("If you want to goto main. select 1!\n");
printf("1. goto main 2. end\n");
cin>>select;
if(select==1)
{
goto main(1);
}
else if(select==2)
{
printf("exiting...");
return 0;
}
}
else if(select==5)
{
system( "data" );
printf("If you want to goto main. select 1!\n");
printf("1. goto main 2. end\n");
cin>>select;
if(select==1)
{
goto main(1);
}
else if(select==2)
{
printf("exiting...");
return 0;
}
}
else if(select==6)
{
system( "time" );
printf("If you want to goto main. select 1!\n");
printf("1. goto main 2. end\n");
cin>>select;
if(select==1)
{
goto main(1);
}
else if(select==2)
{
printf("exiting...");
return 0;
}
}
return 0;
} |
Hit : 10201 Date : 2015/03/28 09:42
|