#include <iostream>


using namespace std;


int main(void){

//This is goto statement! if somebody wanted to go mainmenu, this statement would good friend!


RETRY:



cout<<"############################"<<endl<<"ID: 20131"<<endl<<"Name: "<<endl<<"############################"<<endl<<endl;

cout<<"1. Problem 1"<<endl<<"2. Problem 2"<<endl<<endl<<"0. Exit"<<endl<<endl;

cout<<"Command >>";


//We will infinitely work in menu, except for when selecting exit menu. So, "while statement" will be proper.

while(1){


char OPTION;


cin >> OPTION;


switch(OPTION){


case '1':


cout<<"*Drawing a shape"<<endl;

cout<<"(1-Rectangle, 2-Triangle, 3-Inverted Triangle, 4-Letter 'H', 0-Back to Main Menu)"<<endl;

char MenuNumber;

cout<<"Choose shape>>";

cin>>MenuNumber;

if(MenuNumber == '1'){

for(int column1 = 0; column1 < 5; column1++){

cout<<"*********"<<endl;

}

}

/******************************************************************************************

 * Number 2 and Number 3 is (I guess) very hard. Because We will use several for statement*

 *

 * We think about 4 part. Firstly we must think about line. Second, we must also think abo*

 * ut stars. Specifically, we think two parts of stars. Left side and Right side. Because,*

 * We cannot increase star 2 by 2. So (This is in my range.:)) I divide two parts, Left si*

 * de, and Right side. This is second and Third. And finally we can think about space part*

 * . So Menu 2 and 3 is finish                                                            *

 * ***************************************************************************************/

else if(MenuNumber == '2'){

for(int LINE=0; LINE<5; LINE+=1){


for(int SPACE=4; SPACE>LINE; SPACE--){

cout<<" ";

}


for(int LEFTPART=0; LEFTPART<=LINE; LEFTPART++){

cout<<"*";

}

for(int RIGHTPART=1; RIGHTPART<=LINE; RIGHTPART++){

cout<<"*";

}

cout<<endl;

}

}

else if(MenuNumber == '3'){

for(int LINE1 = 5; LINE1 > 0; LINE1 --){


for(int SPACE1 = 5; SPACE1 > LINE1; LINE1--){

cout<<" ";

}


for(int LEFTPART1 = 0; LEFTPART1 < LINE1; LEFTPART1 ++){

cout<<"*";

}

for(int RIGHTPART1 = 1; RIGHTPART1 < LINE1; RIGHTPART1 ++){

cout<<"*";

}

cout<<endl;

}

}

/********************************************************************

 * Menu 4 is very easy. we can make H beam by two column and bridge.*

 * So, we make bridge intermediately in "for statement"!!. Be carefu*

 * l when you are BeamH = 1. This is pitfall. Because when BeamH =1,*

 * you can see both "**     **" and "*********". So be careful! :)  *

 * *****************************************************************/

else if(MenuNumber == '4'){

for(int BeamH = 0; BeamH < 4; BeamH++){

cout<<"**     **"<<endl;

if(BeamH == 1)

cout<<"*********"<<endl;

}

}

else if(MenuNumber == '0')

goto RETRY;

//This is Error message when you enter strange number or character.

else{

cout<<"Wrong!! Try again!"<<endl;

}

break;


case '2':


cout<<"*Choose Function of Calculator"<<endl;

cout<<"(1-Factorial, 2-Combination, 0-Back to Main Menu)"<<endl;

int OPTIONTWO;

cout<<"Choose function>>";

cin>>OPTIONTWO;

//Problem 2 - 1, Factorial. We must 

if(OPTI 1 {

unsigned long long int nF, ResultF=1;

cout<<"Input of N [n!]>>";

cin>>nF;

for(unsigned long long int count = 1; count < nF+1; count++){

ResultF = ResultF*count;

}

cout<<nF<<"! is "<<ResultF<<endl;

}

else if(OPTI 2){

int nK, nR, Power, Fact1=1, Fact2=1, Fact3=1;

int product;

cout<<"Input of N>>";

cin>>nK;

cout<<"Inout of K>>";

cin>>nR;


Power = nK-nR;

product = (Fact1)/(Fact2*Fact3);

for(int count1 = 1; count1 < nK+1; count1++){

Fact1 = Fact1*count1;

}

for(int count2 = 1; count2 < nR+1; count2++){

Fact2 = Fact2*count2;

}

for(int count3 = 1; count3 <= Power;count3++){

Fact3 = Fact3*count3;

}

cout<<nK<<"C"<<nR<<" is "<< (Fact1)/(Fact2*Fact3) <<endl;

}

else

goto RETRY;

break;


case '0':

cout<<"program is terminating ..."<<endl;


return 0;


default:

cout<<"Wrong Input. Please choose one of the above options."<<endl<<endl;



}

}

}


고수님들 미안한데 질문이 세개욤 ㅠㅠ(방금 신상털릴까봐 신상만 싹 지움 ㅠㅠ)


1. 1번에 3번 무한루프돌음 ㅠㅠㅠ 왜그런지 모르겟음 ㅠㅠ 1번의 2번은 잘만되던데


2. 1번에서 하나 실행하면 1번에 해당하는 메뉴나와야되는데 안나옴 ㅠㅠ 리눅스터미널에서


3. 1번이든 2번이든 끝내고싶으면 0누르고 나와야되는데 goto구문말고 또 방법없음>? ㅜㅠ