zoukankan      html  css  js  c++  java
  • 留念 C语言第一课简单的计算器制作

    留念 C语言第一课简单的计算器制作
    学C语言这么久了。  /* 留念 C语言第一课简单的计算器制作 */ 
     #include<stdio.h>  #include<stdlib.h>
    #include<conio.h>
    void displayMenu(); /*赵存档做*/
    void add();
    void sub();
    void multiply();
    void divide();
    void yushu();
    void jiecheng();
    void leijia();
    void jiechengleijia();
    int main(int n)
    {do
    {system("color 2e");
    system("cls");
    displayMenu();
    system("pause");}
    while(n);}
    int n;
    void displayMenu()
    { printf("***welcome to use simple calculator*** ");
    printf("the author is xiaobo ");
    printf("No.1 add ");
    printf("No.2 sub ");
    printf("No.3 multiply ");
    printf("No.4 divide ");
    printf("No.5 yushu ");
    printf("No.6 jiecheng ");
    printf("No.7 liejia ");
    printf("No.8 jiechengleijia ");
    printf("No.0 exit ");
    scanf("%d",&n);
    switch(n)
    { case 1:add(); break;
    case 2:sub(); break;
    case 3:multiply(); break;
    case 4:divide(); break;
    case 5:yushu(); break;
    case 6:jiecheng(); break;
    case 7:leijia(); break;
    case 8:jiechengleijia();break;
    case 0:exit(0);return;}
    }
    void add()
    { double num1,num2;
    double sum;
    printf("Please Input 2 numbers to add ");
    scanf("%lg%lg",&num1,&num2);
    sum =num1+num2;
    printf("sum is %lg ",sum);}
    void sub()
    { double num1,num2;
    double sum;
    printf("Please Input 2 numbers to sub ");
    scanf("%lg%lg",&num1,&num2);
    sum =num1-num2;
    printf("the result is %lg ",sum);}


    void multiply()
    { double num1,num2;
    double sum;
    printf("Please Input 2 numbers to multiply ");
    scanf("%lg%lg",&num1,&num2);
    sum =num1*num2;
    printf("the result is %lg ",sum);}
    void divide()
    { double num1,num2;
    double sum;
    printf("Please Input 2 numbers to divide ");
    scanf("%lg%lg",&num1,&num2);
    sum =num1/num2;
    printf("the result is %lg ",sum);}

    //http://www.cnblogs.com/xiaobo-Linux/ QQ463431476
    void yushu()
    {int num1,num2;
    int sum;
    printf("please Input 2 numbers for yushu ");
    scanf("%ld",&num1,&num2);
    sum =num1%num2;
    printf("yushu is %ld ",sum);
    }
    void jiecheng()

    {double i,j=1;
    double sum=1;
    printf("Please Input a integer number for jiecheng ");
    scanf("%lg",&i);
    for(;j<i;j++)
    {sum *=j;}
    sum *=i;
    printf("the result is %lg ",sum);}
    void leijia()
    {double n;
    double sum=0;
    printf("please input any number more than 0, with less than 0 number to end ");
    for(n=0;n>=0;)
    {sum +=n;
    scanf("%lg",&n);}
    printf("the result is %lg ",sum); }
    void jiechengleijia()
    { int i,a[5];
    long j,k=1,sum=0;
    printf("please input any 5 integer numbers ");
    for(i=0;i<5;i++)
    {scanf("%d",&a[i]);
    for(j=a[i];j>=1;j--)
    {k =k*j;}
    sum +=k;
    k=1;}
    printf(" the sum is %ld ",sum); }
    /* 2014 /12. 25赵存档 QQ463431476 做 */ 图片 
  • 相关阅读:
    2021 省选颓记
    题解 UVA12459 Bees' ancestors
    题解 UVA10812 Beat the Spread!
    题解 UVA12230 过河 Crossing Rivers
    题解 P1850 [NOIP2016 提高组] 换教室
    题解 P1297 [国家集训队]单选错位
    CSP2020 游记
    学习笔记10-18
    【题解-SP1724 TRICOUNT】简单易懂的递推式写法
    题解:论如何利用 大 模 拟 吊打LGJ~
  • 原文地址:https://www.cnblogs.com/zhaocundang/p/5052107.html
Copyright © 2011-2022 走看看