搜索
查看: 1460|回复: 5
打印 上一主题 下一主题

[原创] 一个 C++ 工具箱

[复制链接]
跳转到指定楼层
楼主
发表于 2014-1-5 13:58:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本人小学6年级 , 没有炫耀的意思,别误会。
  1. #include<iostream>
  2. #include<windows.h>
  3. using std::cout;
  4. using std::cin;
  5. using std::endl;
  6. int jisuan()
  7. {
  8.     int i;
  9.     long double v1,v2;
  10.     char a;
  11.     label1:
  12.     system ("cls");
  13.     cout << "请输入第一个数" <<endl;
  14.     cin >>v1;
  15.     cout << "请输入运算符 + - * /" <<endl;
  16.     cin >>a;
  17.     cout << "请输入第二个数" <<endl;
  18.     cin >>v2;
  19.     switch(a)
  20.     {
  21.         case '+':
  22.             cout << v1 << a << v2 << "=" << v1 + v2;
  23.         break;
  24.         case '-':
  25.             cout << v1 << a << v2 << "=" << v1 - v2;
  26.         break;
  27.         case '*':
  28.             cout << v1 << a << v2 << "=" << v1 * v2;
  29.         break;
  30.         case '/':
  31.             cout << v1 << a << v2 << "=" << v1 / v2;
  32.         break;
  33.     }
  34.     cout << "继续计算请输入1,返回请输入2" <<endl;
  35.     cin >>i;
  36.     if(i==1)
  37.     {
  38.         goto label1;
  39.     }
  40.     else
  41.     {   
  42.         system("cls");
  43.         return 0;
  44.     }                 
  45. }
  46. int sqer()
  47. {
  48.     int i;
  49.     char a;
  50.     long double d_r;
  51.     label1:
  52.     system ("cls");
  53.     cout << "请输入直径或半径" <<endl;
  54.     cin >> d_r;
  55.     cout << "刚才输入半径,现在就输入r,刚才输入半径,现在就输入d" <<endl;
  56.     cin >>a;
  57.     if (a == 'd')
  58.        d_r = d_r/2;
  59.     cout << "周长 " << d_r * 2 * 3.14 <<endl;
  60.     cout << "面积 " << d_r * d_r * 3.14 <<endl;
  61.     cout << "继续计算请输入1,返回请输入2" <<endl;
  62.     cin >>i;
  63.     if(i==1)
  64.     {
  65.         goto label1;
  66.     }
  67.     else
  68.     {   
  69.         system("cls");
  70.         return 0;
  71.     }        
  72. }
  73. int lixi()
  74. {
  75.     int i;
  76.     double dng,year;
  77.     long double yuan,yuaner;
  78.     label1:
  79.     system("cls");
  80.     cout << "请输入本金" <<endl;
  81.     cin  >>yuan;
  82.     cout << "请输入利率 (小数)" <<endl;
  83.     cin  >>dng;
  84.     cout << "请输入年数" <<endl;
  85.     cin  >>year;
  86.     yuaner = yuan * dng * year;
  87.     cout << "利息:" << yuaner <<endl;
  88.     cout << "总共:" << yuan + yuaner <<endl;
  89.     cout << "继续计算请输入1,返回请输入2" <<endl;
  90.     cin >>i;
  91.     if(i==1)
  92.     {
  93.         goto label1;
  94.     }
  95.     else
  96.     {   
  97.         system("cls");
  98.         return 0;
  99.     }
  100. }
  101. int juxing()
  102. {
  103.     int i;
  104.     long double a,b,a_b;
  105.     label1:
  106.     system("cls");
  107.     cout <<"请输入长" <<endl;
  108.     cin >>a;
  109.     cout <<"请输入宽" <<endl;
  110.     cin >>b;
  111.     a_b = a + b;
  112.     cout <<"周长是" <<a_b * 2 <<endl;
  113.     cout <<"面积是" <<a*b <<endl;
  114.     cout <<"继续计算请输入1,返回请输入2"<<endl;
  115.     cin >>i;
  116.     if(i==1)
  117.     {
  118.         goto label1;
  119.     }
  120.     else
  121.     {
  122.         system("cls");
  123.         return 0;
  124.     }         
  125. }
  126. int time()
  127. {
  128.     int i;
  129.     system ("cls");
  130.     cout <<"修改时间请输入1,返回请输入2" <<endl;
  131.     cin >>i;
  132.     if (i == 1)
  133.     {
  134.           system("time");
  135.     }
  136.     else
  137.     {
  138.         system("cls");
  139.         return 0;
  140.     }
  141.          
  142. }
  143. int times()
  144. {
  145.     int i ,times;
  146.     system("cls");
  147.     cout <<"继续请输入1,返回请输入2" <<endl;
  148.     cin >>i;
  149.     if(i == 1)         
  150.     {
  151.         cout <<"请输入时间(单位正整数秒)" <<endl;
  152.         cin >>times;
  153.         while (times >= 0)
  154.         {
  155.             system("cls");
  156.             cout <<"还剩" <<times <<"秒关机,请不要关闭程序" <<endl;
  157.             Sleep(1000);
  158.             --times;
  159.         }
  160.         system("shutdown /s");
  161.     }
  162.     else
  163.     {
  164.         system("cls");
  165.         return 0;
  166.     }
  167. }
  168. int cand()
  169. {
  170.     int i;  
  171.     label1:
  172.     system("cls");
  173.     cout <<"关机请输入 1 ,重启请输入 2 ,返回请输入 3" <<endl;
  174.     cin >> i;
  175.     switch(i)
  176.     {
  177.         case 1:
  178.             system("shutdown /s");
  179.         break;
  180.         case 2:
  181.             system("shutdown /r");
  182.         break;
  183.         case 3:
  184.             system("cls");
  185.             return 0;
  186.         break;
  187.         default:
  188.             cout <<"输入有误,请重新输入!" <<endl;
  189.             system("pause");
  190.             goto label1;
  191.         break;   
  192.     }
  193. }
  194. int main()
  195. {
  196.     int i;
  197.     label1:
  198.     cout <<"欢迎使用多功能工具箱" <<endl;
  199.     cout <<"1.计算器" <<endl;
  200.     cout <<"2.圆形计算器" <<endl;
  201.     cout <<"3.利息计算器" <<endl;
  202.     cout <<"4.矩形计算器" <<endl;
  203.     cout <<"5.修改时间" <<endl;
  204.     cout <<"6.定时关机" <<endl;
  205.     cout <<"7.立即关机 或 重启" <<endl;
  206.     cout <<"8.退出程序" <<endl;
  207.     cout <<"请输入序号" <<endl;
  208.     cin >> i;
  209.     switch(i)
  210.     {
  211.          case 1:
  212.               jisuan();
  213.               goto label1;   
  214.          break;
  215.          case 2:
  216.               sqer();
  217.               goto label1;                  
  218.          break;
  219.          case 3:
  220.               lixi();
  221.               goto label1;   
  222.          break;
  223.          case 4:
  224.               juxing();
  225.               goto label1;     
  226.          break;
  227.          case 5:
  228.               time();
  229.               goto label1;   
  230.          break;
  231.          case 6:
  232.               times();
  233.               goto label1;   
  234.          break;
  235.          case 7:
  236.               cand();
  237.               goto label1;
  238.          break;
  239.          case 8:
  240.               cout<< "感谢您的使用" <<endl;
  241.               system("pause");
  242.               return 0;   
  243.          break;
  244.          default:
  245.              cout <<"输入有误,请重新输入!" <<endl;
  246.              system("pause");
  247.              system("cls");
  248.              goto label1;
  249.              break;      
  250.     }
  251. }
复制代码
沙发
发表于 2014-1-15 09:20:09 | 只看该作者
我来试试看
板凳
发表于 2014-4-5 22:16:17 | 只看该作者
小学生很厉害啊
地板
发表于 2015-2-5 18:24:53 | 只看该作者
不建议使用goto,但这个工具箱的确牛!!
5#
发表于 2015-3-9 13:19:55 | 只看该作者
同六年级,也做过类似的东西
6#
发表于 2015-5-12 19:44:28 | 只看该作者
我同六年级
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表