#include
#include
Void menu (void)
{
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- the menu -- -- -- -- -- -- -- -- -- -- -- -- -- \ n ");
Printf (" addition. \ n ");
Printf (" 2. Subtraction. \ n ");
Printf (" 3. Multiplication. \ n ");
Printf (" 4. Divide. \ n ");
Printf (" 0. Exit. \ n ");
Printf (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - \ n ");
Printf (" please select [0-4] : ");
}
Int sele (void)
{
int n=0;
Scanf_s (" % d ", & amp; n);
If (n & gt; 4 | | n & lt; 0)
{
Printf (" please enter a number (0 to 4) \ n ");
System (" PAUSE ");
system("cls");
The menu ();
Sele ();
}
The else
{
return n;
}
}
Int the get (void)
{
int n=0;
Printf (" please enter a number: ");
Scanf_s (" % d ", & amp; n);
return n;
}
Int main (void)
{
Int fir=0, the SEC=0;
system("cls");
The menu ();
The switch (sele ())
{
Case 1:
While (1)
{
Fir=the get ();
The SEC=the get ();
Printf (" % d % d=% d \ n ", fir, the SEC, fir + SEC);
System (" PAUSE ");
system("cls");
The menu ();
The main ();
}
Case 2:
While (1)
{
Fir=the get ();
The SEC=the get ();
Printf (" % d, % d=% d \ n ", fir, the SEC, fir - SEC);
System (" PAUSE ");
system("cls");
The menu ();
The main ();
}
Case 3:
While (1)
{
Fir=the get ();
The SEC=the get ();
Printf (" % d % d *=% d \ n ", fir, the SEC, fir * SEC);
System (" PAUSE ");
system("cls");
The menu ();
The main ();
}
Case 4:
While (1)
{
Fir=the get ();
The SEC=the get ();
/printf (" % d % d=% d \ n ", fir, the SEC, fir/SEC).
System (" PAUSE ");
system("cls");
The menu ();
The main ();
}
Case 0:
While (1)
{
Printf (" have quit, thank you for using \ n ");
exit(0);
System (" PAUSE ");
system("cls");
The menu ();
The main ();
}
Default: break;
}
return 0;
}
CodePudding user response:
Int sele (void) function calls sele nested inside (); . This is not good,Not to try so, hand to code test:
int sele (void)
{
int n=0;
Do
{
Printf (" please enter a number (0 to 4) \ n ");
Scanf_s (" % d ", & amp; n);
} while (n & gt; 4 | | n & lt; 0);
return n;
}
Other code did not look,
CodePudding user response:
Your main () function calls the main function is nested inside the,You can consult the code structure:
http://bbs.csdn.net/topics/392285790
CodePudding user response:
write a menu program to run in the first place in the screen shows the following menu after, when the input value of 1, call display with "& amp;" The patterns of the character representation function application pattern (definition); After input number 2, call display with a "$" character representation of design function program (design) his definitions; Input value after 3 program,
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Menu section *
* 1. The Design (& amp;) *
* 2. The Design ($) *
* 3. The Exit *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
EndFlag=0;
Do
{
PrintMenu ();
Printf (" please input your choice: ");
The scanf (" % d ", & amp; Choice);
The switch (choice)
{
Case 1:
The design (' & amp; ');
break;
Case 2:
The design (' $');
break;
Case 3:
EndFlag=1;
break;
Default:
Printf (" input error, please input again \ n ");
break;
}
} while (! EndFlag);