博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
留念 C语言第一课简单的计算器制作
阅读量:6828 次
发布时间:2019-06-26

本文共 2483 字,大约阅读时间需要 8 分钟。

留念 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***\n");
printf("the author is xiaobo\n");
printf("No.1 add\n");
printf("No.2 sub\n");
printf("No.3 multiply\n");
printf("No.4 divide\n");
printf("No.5 yushu\n");
printf("No.6 jiecheng\n");
printf("No.7 liejia\n");
printf("No.8 jiechengleijia\n");
printf("No.0 exit\n");
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\n");
scanf("%lg%lg",&num1,&num2);
sum =num1+num2;
printf("sum is %lg\n",sum);}
void sub()
{ double num1,num2;
double sum;
printf("Please Input 2 numbers to sub\n");
scanf("%lg%lg",&num1,&num2);
sum =num1-num2;
printf("the result is %lg\n",sum);}
void multiply()
{ double num1,num2;
double sum;
printf("Please Input 2 numbers to multiply\n");
scanf("%lg%lg",&num1,&num2);
sum =num1*num2;
printf("the result is %lg\n",sum);}
void divide()
{ double num1,num2;
double sum;
printf("Please Input 2 numbers to divide\n");
scanf("%lg%lg",&num1,&num2);
sum =num1/num2;
printf("the result is %lg\n",sum);}
//http://www.cnblogs.com/xiaobo-Linux/ QQ463431476
void yushu()
{int num1,num2;
int sum;
printf("please Input 2 numbers for yushu\n");
scanf("%ld",&num1,&num2);
sum =num1%num2;
printf("yushu is %ld\n",sum);
}
void jiecheng()
{double i,j=1;
double sum=1;
printf("Please Input a integer number for jiecheng\n");
scanf("%lg",&i);
for(;j<i;j++)
{sum *=j;}
sum *=i;
printf("the result is %lg\n",sum);}
void leijia()
{double n;
double sum=0;
printf("please input any number more than 0, with less than 0 number to end\n");
for(n=0;n>=0;)
{sum +=n;
scanf("%lg",&n);}
printf("the result is %lg\n",sum); }
void jiechengleijia()
{ int i,a[5];
long j,k=1,sum=0;
printf("please input any 5 integer numbers\n");
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("\nthe sum is %ld\n",sum); }
/* 2014 /12. 25赵存档 QQ463431476 做 */
图片 
你可能感兴趣的文章
腾讯,百度,网易游戏,华为笔面经验
查看>>
PyTalk : a Jabber Client un Python using xmpppy and PyQt4
查看>>
利用ResultFilter实现asp.net mvc 页面静态化
查看>>
C++类构造函数初始化列表(转)
查看>>
13最佳WordPress的维护插件
查看>>
Missing Screenshot 的解决方案
查看>>
jQuery:1.5.1,复选框应用(全选,全不选,反选,提交选中的值,全选/全不选)...
查看>>
jQuery:1.5.4.3,表格变色(单击行,把当行的单选按钮(radio)设为选中状态,并应用当前样式)...
查看>>
oracle11gR2安装示例数据库
查看>>
解决ssh的"Write failed: Broken pipe"问题
查看>>
Java 网络编程(五) 使用TCP/IP的套接字(Socket)进行通信
查看>>
chromium如何新增extension API以及添加内部扩展
查看>>
拒绝alert调试js,浏览器调试js大全(火狐firefox浏览器,谷歌chrome 浏览器,微软ie9浏览器等)...
查看>>
EJDB 1.1.18 发布,嵌入式JSON数据库
查看>>
session和cookie的联系
查看>>
Go Revel - Templates(模板)
查看>>
《深入理解Nginx》阅读与实践(三):使用upstream和subrequest访问第三方服务
查看>>
NGUI:HUD Text(头顶伤害漂浮文字)
查看>>
HTML/CSS/Javascript代码在线压缩、格式化(美化)工具
查看>>
linux命令学习-复制(cp,scp)
查看>>