c语言例题
C 语言实例 - 实现简单的计算器
实现加减乘除计算。
# include stdio.h
int main() {
char operator;
double firstNumber,secondNumber;
printf("输入操作符 (+, -, *,): ");
scanf("%c", operator);
printf("输入两个数字: ");
scanf("%lf %lf", firstNumber, secondNumber);
switch(operator)
{
case '+':
printf("%.1lf + %.1lf = %.1lf",firstNumber, secondNumber, firstNumber + secondNumber);
break;
case '-':
printf("%.1lf - %.1lf = %.1lf",firstNumber, secondNumber, firstNumber - secondNumber);
break;
case '*':
printf("%.1lf * %.1lf = %.1lf",firstNumber, secondNumber, firstNumber * secondNumber);
break;
case '/':
printf("%.1lf / %.1lf = %.1lf",firstNumber, secondNumber, firstNumber / secondNumber);
break;
// operator doesn't match any case constant (+, -, *, /)
default:
printf("Error! operator is not correct");
}
return 0;
}
用c 编写的计算器
推荐内容
用c 编写的计算器
以下是自己编写的代码,麻烦高手看看哪边错的?
#include "stdio.h"
#include "stdlib.h"
#include "conio.h"
int jmzhz(void);
int jsgc(float a,char c,float b, float x);
int main(void)
{
float a,b,x;
char c,d;
printf("简单计算器 设计者:**\n");
jmzhz();
gotoxy(15,3);
scanf("%f%c%f", a, c,
gotoxy(15,4);
jsgc(a,c,b,x);
gotoxy(15,5);
printf("是否要继续进行:y or n or j\n");
gotoxy(15,6);
scanf("%c",
scanf("%c",
while(d=='y')
{
system("cls");
printf("简单计算器 设计者:**\n");
jmzhz();
gotoxy(15,3);
scanf("%f%c%f", a, c,
gotoxy(15,4);
jsgc(a,c,b,x);
gotoxy(15,5);
printf("是否要继续进行:y or n or j\n");
gotoxy(15,6);
scanf("%c",
scanf("%c",
}
while(d=='j')
{
system("cls");
printf("简单计算器 设计者:**\n");
jmzhz();
gotoxy(15,3);
a=x;
printf("%f",a);
scanf("%c%f", c,
gotoxy(15,4);
jsgc(a,c,b,x);
gotoxy(15,5);
printf("是否要继续进行:y or n or j\n");
gotoxy(15,6);
scanf("%c",
scanf("%c",
}
if(d=='n')
{
system("cls");
printf("简单计算器 设计者:**\n");
jmzhz();
}
return 0;
}
int jmzhz(void)
{
printf(" ***********************************\n");
printf(" | |\n");
printf(" | |\n");
printf(" | |\n");
printf(" | |\n");
printf(" ###################################\n");
printf(" | 1 2 3 + |\n");
printf(" | 4 5 6 - |\n");
printf(" | 7 8 9 * |\n");
printf(" | 0 . = / |\n");
printf(" ***********************************\n");
return 0;
}
int jsgc(float a,char c,float b,float x)
{
float m;
if(c=='+')
x=a+b;
if(c=='-')
x=a-b;
if(c=='*')
x=a*b;
if(c=='/' b!=0)
x=a/b;
if(c=='/' b==0)
{
printf("warning!\n");
return 0;
}
printf("=%f",x);
return 0;
}
展开
来自匿名用户的提问
回答
最佳答案
错误在于 此函数int jsgc(float a,char c,float b, float x); 参数x传值调用,并不会修改主函数中的x值,应改成传址int jsgc(float a,char c,float b, float *x); 另外程序控制改成switch分支比较好。修改后的源码如下:
#include stdio.h
#include stdlib.h
#include conio.h
int jmzhz(void);
int jsgc(float a,char c,float b, float *x);
int main(void)
{
float a,b,x;
char c,d,flag=1;
printf("简单计算器 设计者:**\n");
jmzhz();
gotoxy(15,3);
scanf("%f%c%f", a, c,
gotoxy(15,4);
jsgc(a,c,b,
gotoxy(15,5);
printf("是否要继续进行:y or n or j\n");
gotoxy(15,6);
scanf("%c",
scanf("%c",
while(flag)
{
switch(d)
{
case 'y':
system("cls");
printf("简单计算器 设计者:**\n");
jmzhz();
gotoxy(15,3);
scanf("%f%c%f", a, c,
gotoxy(15,4);
jsgc(a,c,b,
gotoxy(15,5);
printf("是否要继续进行:y or n or j\n");
gotoxy(15,6);
scanf("%c",
scanf("%c",
break;
case 'j':
system("cls");
printf("简单计算器 设计者:**\n");
jmzhz();
gotoxy(15,3);
a=x;
printf("%f",a);
scanf("%c%f", c,
gotoxy(15,4);
jsgc(a,c,b,
gotoxy(15,5);
printf("是否要继续进行:y or n or j\n");
gotoxy(15,6);
scanf("%c",
scanf("%c",
break;
case 'n':
system("cls");
printf("简单计算器 设计者:**\n");
jmzhz();
flag = 0;
break;
default:
system("cls");
printf("错误的命令,程序将退出!\n简单计算器 设计者:**\n");
flag = 0;
break;
}
}
getchar();
return 0;
}
int jmzhz(void)
{
printf(" ***********************************\n");
printf(" | |\n");
printf(" | |\n");
printf(" | |\n");
printf(" | |\n");
printf(" ###################################\n");
printf(" | 1 2 3 + |\n");
printf(" | 4 5 6 - |\n");
printf(" | 7 8 9 * |\n");
printf(" | 0 . = / |\n");
printf(" ***********************************\n");
return 0;
}
int jsgc(float a,char c,float b,float *x)
{
float m;
if(c=='+')
(*x)=a+b;
if(c=='-')
(*x)=a-b;
if(c=='*')
(*x)=a*b;
if(c=='/' b!=0)
(*x)=a/b;
if(c=='/' b==0)
{
printf("warning!\n");
return 0;
}
printf("=%f",*x);
return 0;
}
C语言 计算器程序
推荐内容
C语言 计算器程序
输入任意四则混合运算式,求结果
是四则运算式的哈 刚写的那个没得发运行 只有两则的运算式才可以
来自samantha的提问
回答
最佳答案
#include"stdio.h"
void main()
{
float a,b,c;
char s;
printf("输入:");
scanf("%f%c%f", a, s,
if(s=='+')
b=a+c;
if(s=='-')
b=a-c;
if(s=='*')
b=a*c;
if(s=='/')
b=a/c;
printf("%.2f\n",b);
}
2009-06-02
关于c语言计算器
推荐内容
关于c语言计算器
麻烦高手帮忙改一下下面的插入的程序,自己写的,错太多了
#include
#include
void displayMenu();
double jiafa(double num1,double num2);
double jianfa(double num1,double num2);
double chengfa(double num1,double num2);
double chufa(double num1,double num2);
int qiuyu(int n,int m);
int leijia(int n,int m);
int jiecheng(n);
int paileizuhe(int n,int m);
main()
{
double num1,num2;
int n,m;
double result;
int item;
}
while(1)
{
displayMenu();
printf("请选择一项功能;");
scanf("%d", item);
switch(item)
{
case 1 :
printf("请输入两个数:");
scanf("%lf%lf", num1, num2);
result=jiafa(num1,num2);
printf("%lf+%lf结果为:%lf\n",num1,num2,result);
break;
case 2 :
printf("请输入两个数:");
scanf("%lf%lf", num1, num2);
result=jianfa(num1,num2);
printf("%lf-%lf结果为:%lf\n",num1,num2,result);
break;
case 3:
printf("请输入两个数:");
scanf("%lf%lf", num1, num2);
result=chengfa(num1,num2);
printf("%lf*%lf结果为:%lf\n",num1,num2,result);
break;
case 4:
printf("请输入两个数:");
scanf("%lf%lf", num1, num2);
result=chengfa(num1,num2);
printf("%lf/%lf结果为:%lf\n",num1,num2,result);
break;
case 5:
printf("请输入两个整数\n");
scanf("%d,%d", n,
result=qiuyu(n,m);
printf("余数是%d\n",n%m);
break;
case 6:
printf("请输入两个整数n和m(nm)
{
tmp=n;n=m;m=tmp;
}
for (index=n,index index++)
{
result+=index;
}
return result;
}
int jiecheng(n);
{
int result=1;
int index;
for(index=1;index index++)
{
result=result*index;
}
return result;
}
int paileizuhe(int n,int m);
{
int result;
int tmp;
int index;
if (n m)
{
tmp=n;n=m;m=tmp;
}
{ result=((m!)*((n-m)!));}
return result;
}
void displayMenu()
{
printf("========计算器程序主菜单=========\n");
printf("| 1 加法 |\n");
printf("| 2 减法 |\n");
printf("| 3 乘法 |\n");
printf("| 4 除法 |\n");
printf("| 5 求余 |\n");
printf("| 6 累加 |\n");
printf("| 7 阶乘 |\n");
printf("| 8 排列组合 |\n");
printf("| 0 退出 |\n");
printf("===============================\n");
}
printf("%.6lf\n", result);
}
return 0;
}
来自匿名用户的提问
回答
最佳答案
老师说,格式真的很重要啊!
#include stdio.h
#include math.h
#include "stdlib.h"
void displayMenu();
double jiafa(double num1,double num2);
double jianfa(double num1,double num2);
double chengfa(double num1,double num2);
double chufa(double num1,double num2);
int qiuyu(int n,int m);
int leijia(int n,int m);
int jiecheng(n);//n的类型!
int paileizuhe(int n,int m);
main() //不返回值就用void定义
{
double num1,num2;
int n,m;
double result;
int item;
} 不该有"}"
while(1)
{
displayMenu();
printf("请选择一项功能;"); //别用中文标点
scanf("%d", item);
switch(item)
{
case 1 :
printf("请输入两个数:");
scanf("%lf%lf", num1, num2);
result=jiafa(num1,num2);
printf("%lf+%lf结果为:%lf\n",num1,num2,result);
break;
case 2 :
printf("请输入两个数:");
scanf("%lf%lf", num1, num2);
result=jianfa(num1,num2);
printf("%lf-%lf结果为:%lf\n",num1,num2,result);
break;
case 3:
printf("请输入两个数:");
scanf("%lf%lf", num1, num2);
result=chengfa(num1,num2);
printf("%lf*%lf结果为:%lf\n",num1,num2,result);
break;
case 4:
printf("请输入两个数:");
scanf("%lf%lf", num1, num2);
result=chengfa(num1,num2);
printf("%lf/%lf结果为:%lf\n",num1,num2,result);
break;
case 5:
printf("请输入两个整数\n");
scanf("%d,%d", n,
result=qiuyu(n,m);
printf("余数是%d\n",n%m);
break;
case 6:
printf("请输入两个整数n和m(n m):");
scanf("%d,%d", n,
result=leijia(n,m);
printf("结果为:%d",n,m,result);
break;
case 7:
printf("请输入1个数:");
scanf("%d",%n);//n前面多了百分号
result=jiecheng(n);
printf("结果为:%d",n,result);
break;
case 8:
printf("请输入两个整数:\n");
scanf("%d,%d", n,
result=paileizuhe(int n,int m);//定义函数的时候才需要类型
printf("结果是%d\n",(n!)*((n-m)!));//C里面的阶乘可不是n!
break;
case 0:
exit(0);
default :
printf("您输入的有错误!!!\n");
}
while(getcher() ! = '\n'); //是getchar, !=别分开了
}
//少了"}"
double jiadfa(double num1,double num2)
{
double result;
result=num1+num2;
return result;
}
double jianfa(double num1,double num2)
{
double result;
result=num1-num2;
return result;
}
double chengfa(double num1,double num2)
{
double result;
result=num1*num2;
return result;
}
double chufa(double num1,double num2)
{
double result;
if(0==num2)
{
printf("0不能作为除数!!!!\n");
}
else
{
result=num1/num2;
return result;
}
}
int qiuyu(int n,int m);//又是分号 ,类型定义和返回值不符,要么改定义要么改result的类型
{
double result;
if(m==b)//是零不是b
{
printf("0不能作为除数!!!!\n");
}
else
{
result=n%m;
return result;
}
}
int leijia(int n,int m);//不要有分号! result类型和返回值
{
double result=0.0;
int tmp;
int index;
if (n m)
{
tmp=n;n=m;m=tmp;
}
for (index=n,index index++) //是分号不是逗号
{
result+=index;
}
return result;
}
int jiecheng(n)//n的类型!
{
int result=1;
int index;
for(index=1;index index++)
{
result=result*index;
}
return result;
}
int paileizuhe(int n,int m);//分号!
{
int result;
int tmp;
int index;
if (n m)
{
tmp=n;n=m;m=tmp;
}
{ result=((m!)*((n-m)!));}
return result;
}
void displayMenu()
{
printf("========计算器程序主菜单=========\n");
printf("| 1 加法 |\n");
printf("| 2 减法 |\n");
printf("| 3 乘法 |\n");
printf("| 4 除法 |\n");
printf("| 5 求余 |\n");
printf("| 6 累加 |\n");
printf("| 7 阶乘 |\n");
printf("| 8 排列组合 |\n");
printf("| 0 退出 |\n");
printf("===============================\n");
}多了"}"!
printf("%.6lf\n", result); //这句拿来干嘛?
}又多了!
return 0; //空就别返回
}
2010-11-10
c语言编写计算器
推荐内容
c语言编写计算器
void main()
{
double num1=0;
double num2=0;
char ch;
double count=0;
printf("num1");
scanf("%f", num1);
printf("num2");
scanf("%f", num2);
printf("[+-*/]");
getchar();
scanf(" c", ch);
switch(ch)
{
case '+':
count = num1+num2;
printf("%f", count);
break;
}
printf("%ch", ch);
getch();
// getch();
}
这里输出 ch的结果是 gh并不是+ 是怎么回事?
5来自*的提问
回答
最佳答案
你这程序一眼就看出很多错误。scanf(" c", ch); printf("%f", count); printf("%ch", ch); 你基本的输入输出都没搞懂
2011-06-13
抢首赞
其他回答1条回答
Reson
1.把你所有的double 改为 float ,或者把scanf("%f", num1);里面的“%f” 改为“%l f ”。
2.printf("%ch", ch); printf怎么能用 呢??这是区地址符啊。。要仔细哦······嗯嗯,一下是我改过来的。。
还有什么问题,欢迎继续追问,,谢谢!!!
#include stdio.h
#include conio.h
void main()
{
float num1=0;
float num2=0;
char ch;
float count=0;
printf("num1");
scanf("%f", num1);
printf("num2");
scanf("%f", num2);
getchar();
printf("[+-*/]");
scanf("%c", ch);
//
switch(ch)
{
case '+': count = num1+num2;
break;
}
printf("%f",count);
printf("%c",ch);
getch();
// getch();
}
2011-06-13
C语言 程序设计 计算器
推荐内容
C语言 程序设计 计算器
a)输出计算器界面如下
1 2 3 +
4 5 6 -
7 8 9 *
0 = /
实现整数的算术运算(加,减,乘,除)
b) 浮点型的算术运算功能(加,减,乘,除).
此题适合在turboc2.0环境中开发,用bioskey()函数一个一个的输入字符,判别输入的字符再做出相应的处理。
300来自大大〃的提问
回答
最佳答案
#include#include #include #define NULL 0 #define LEN sizeof(struct student) struct student {long num; char name[20]; float s[4]; struct student *next; }; int n; struct student *readin(void) {struct student *head; struct student *p1,*p2; float x,y,z; n=0; p1=(struct student *)malloc(LEN); p2=p1; scanf("%ld%s%f%f%f", p1- num,p1- name, x, y, p1- s[0]=x; p1- s[1]=y; p1- s[2]=z; p1- s[3]=((x+y+z)/3); while(p1- num!=NULL) {n=n+1; if(n==1)head=p1; else {p2- next=p1; p2=p1; } p1=(struct student *)malloc(LEN); scanf("%ld%s%f%f%f", p1- num,p1- name, x, y, p1- s[0]=x; p1- s[1]=y; p1- s[2]=z; p1- s[3]=((x+y+z)/3); } p2- next=NULL; return(head); } struct student *taxis(struct student *x) {struct student *p3,*p4,*p5,*q; int i; p3=x- next; p4=x; for(i=0;inum!=0) {if(p4- s[3] =p3- s[3]) {if(p4==x) {q=p3; p4- next=p3- next; p3- next=p4; p3=p4- next; x=q; p5=q; } else {p5- next=p3; p4- next=p3- next; p3- next=p4; p5=p3; p3=p4- next; } } else {if(p4==x) {p5=x; p4=p3; p3=p3- next; q=x; } else {p5=p4; p4=p3; p3=p3- next; } } } p3=x- next; p4=x; } return(q); } struct student *insert(struct student *o) {struct student *pl,*p6,*p7,*p8,*head; float a,b,c; int w=0; printf("input a student data!\n"); pl=(struct student *)malloc(LEN); scanf("%ld%s%f%f%f", pl- num,pl- name, a, b, pl- s[0]=a; pl- s[1]=b; pl- s[2]=c; pl- s[3]=((a+b+c)/3); p6=o; p7=o; p8=o- next; while(p6- num!=0 w!=1) {if(p6- s[3] pl- s[3]) {if(p6==o) {if(p8- num!=0) {head=p6; p6=o- next; p8=p8- next; } else {head=p6; p6- next=pl; pl- next=0; w=1; } } else {if(p8- num==0) {p6- next=pl; pl- next=0; w=1; } else {p6=p6- next; p7=p7- next; p8=p8- next; } } } else {if(p6==o) {head=pl; pl- next=o; w=1; } else {p7- next=pl; pl- next=p6; w=1; } } } return(head); } void search(struct student *pn) {struct student *p4,*p5; char na[20]; int u=1; p4=pn; p5=pn; printf("please input the name:\n"); scanf("%s", na); while(strcmp((p4- name),na)!=0 u!=0) {p5=p5- next; p4=p5; if(p5- num==0)u=0; } if(p4- num!=0) printf("%-12ld%s%8.1f%8.1f%8.1f%8.1f\n",p4- num,p4- name,p4- s[0],p4- s[1],p4- s[2],p4- s[3]); else {printf("Please input the right name!\n"); search(pn); } } void save(struct student *ps) {FILE *fp; int i; struct student *p11,*p12; p11=ps; p12=ps; if((fp=fopen("D:\\score.txt","w"))==NULL) {printf("cannot open file\n"); return; } while(p12- num!=0) {fwrite(p11,sizeof(struct student),1,fp); p12=p12- next; p11=p12; } fclose(fp); printf("save in D:\\score.txt!\n"); } extern void show(struct student *x) {struct student *p5; p5=x; if(x!=NULL) do {printf("%-12ld%s%8.1f%8.1f%8.1f%8.1f",p5- num,p5- name,p5- s[0],p5- s[1],p5- s[2],p5- s[3]); p5=p5- next; printf("\n"); } while(p5- num!=0); } #define ONE "input 1 to insert a student data, input 2 to search a student data,\ninput 3 to save all students data, input 4 to printf all, input 0 to exit!\n" void main() {struct student *p,*k,*f; int t; printf("input students'number(Tab)name(Tab)score1(Tab)score2(Tab)score(Enter)\n"); printf("and input 0 0 0 0 0 to end input!\n"); p=readin(); if(n!=1) k=taxis(p); f=k; printf(ONE); scanf("%d", while(t!=0) {if(t==1||t==2||t==3||t==4) {if(t==1)f=insert(f); if(t==2)search(f); if(t==3)save(f); if(t==4)show(f); } else printf("error!\n"); scanf("%d", } getch(); exit(0); } 使用说明: 注意:使用TURBO C++3.0进行编译时候,需要在File\Change Directory 选项将ex保存的路径(ex文件直接放在TC的的下一层,即与Project同层)输入Directory Name 再进行编译.使用File\Open打开文件. 使用WIN-TC可以直接打开就可以编译了.
2008-07-07
抢首赞
其他回答3条回答
Aoin
专为C++爱好者准备的学习空间 /bbs/
期待你的加入
2008-07-10
抢首赞
消失的圣剑
这个是你要的嘛??能实现数字的累加。累乘等。但是还是存在一定的小问题。输出了会退出程序。很简单的,只用了两个switch语句就实现了,并且一个swith是永不运行,只有满足条件后才会跳转运行。这样在速度上是很块的。并且对数据的输入采用了单精度这样也节约了内存空间。。(结果采用了双精度)
#include"conio.h"
#define ESC 27
main()
{int m;
double total;
float a,c,d,x;
char b,n;
head: printf("\npress ESC to Exit!press any key to continue!\n");
m=getch();
if(m!=ESC)
{printf("input the number like a*b,end with enter!\n");
scanf("%f%c%f", a, b,
switch(b)
{case '*':total=a*c;printf("%f",total);break;
case '/':total=a/c;printf("%f",total);break;
case '+':total=a+c;printf("%f",total);break;
case '-':total=a-c;printf("%f",total);break;
}
goto head1;
}
else printf("\a\nBad data!\n");
while(0)
{head1:n=getche();
switch(n)
{case '*':{scanf("%f", total=total*x;printf("%f",total);goto head1;}break;
case '/':{scanf("%f", total=total/x;printf("%f",total);goto head1;}break;
case '+':{scanf("%f", total=total+x;printf("%f",total);goto head1;}break;
case '-':{scanf("%f", total=total-x;printf("%f",total);goto head1;}break;
}
}
}
2008-07-10
抢首赞
我佛拈花一笑
#include#include #include #define NULL 0 #define LEN sizeof(struct student) struct student {long num; char name[20]; float s[4]; struct student *next; }; int n; struct student *readin(void) {struct student *head; struct student *p1,*p2; float x,y,z; n=0; p1=(struct student *)malloc(LEN); p2=p1; scanf("%ld%s%f%f%f", p1- num,p1- name, x, y, p1- s[0]=x; p1- s[1]=y; p1- s[2]=z; p1- s[3]=((x+y+z)/3); while(p1- num!=NULL) {n=n+1; if(n==1)head=p1; else {p2- next=p1; p2=p1; } p1=(struct student *)malloc(LEN); scanf("%ld%s%f%f%f", p1- num,p1- name, x, y, p1- s[0]=x; p1- s[1]=y; p1- s[2]=z; p1- s[3]=((x+y+z)/3); } p2- next=NULL; return(head); } struct student *taxis(struct student *x) {struct student *p3,*p4,*p5,*q; int i; p3=x- next; p4=x; for(i=0;inum!=0) {if(p4- s[3] =p3- s[3]) {if(p4==x) {q=p3; p4- next=p3- next; p3- next=p4; p3=p4- next; x=q; p5=q; } else {p5- next=p3; p4- next=p3- next; p3- next=p4; p5=p3; p3=p4- next; } } else {if(p4==x) {p5=x; p4=p3; p3=p3- next; q=x; } else {p5=p4; p4=p3; p3=p3- next; } } } p3=x- next; p4=x; } return(q); } struct student *insert(struct student *o) {struct student *pl,*p6,*p7,*p8,*head; float a,b,c; int w=0; printf("input a student data!\n"); pl=(struct student *)malloc(LEN); scanf("%ld%s%f%f%f", pl- num,pl- name, a, b, pl- s[0]=a; pl- s[1]=b; pl- s[2]=c; pl- s[3]=((a+b+c)/3); p6=o; p7=o; p8=o- next; while(p6- num!=0 w!=1) {if(p6- s[3] pl- s[3]) {if(p6==o) {if(p8- num!=0) {head=p6; p6=o- next; p8=p8- next; } else {head=p6; p6- next=pl; pl- next=0; w=1; } } else {if(p8- num==0) {p6- next=pl; pl- next=0; w=1; } else {p6=p6- next; p7=p7- next; p8=p8- next; } } } else {if(p6==o) {head=pl; pl- next=o; w=1; } else {p7- next=pl; pl- next=p6; w=1; } } } return(head); } void search(struct student *pn) {struct student *p4,*p5; char na[20]; int u=1; p4=pn; p5=pn; printf("please input the name:\n"); scanf("%s", na); while(strcmp((p4- name),na)!=0 u!=0) {p5=p5- next; p4=p5; if(p5- num==0)u=0; } if(p4- num!=0) printf("%-12ld%s%8.1f%8.1f%8.1f%8.1f\n",p4- num,p4- name,p4- s[0],p4- s[1],p4- s[2],p4- s[3]); else {printf("Please input the right name!\n"); search(pn); } } void save(struct student *ps) {FILE *fp; int i; struct student *p11,*p12; p11=ps; p12=ps; if((fp=fopen("D:\\score.txt","w"))==NULL) {printf("cannot open file\n"); return; } while(p12- num!=0) {fwrite(p11,sizeof(struct student),1,fp); p12=p12- next; p11=p12; } fclose(fp); printf("save in D:\\score.txt!\n"); } extern void show(struct student *x) {struct student *p5; p5=x; if(x!=NULL) do {printf("%-12ld%s%8.1f%8.1f%8.1f%8.1f",p5- num,p5- name,p5- s[0],p5- s[1],p5- s[2],p5- s[3]); p5=p5- next; printf("\n"); } while(p5- num!=0); } #define ONE "input 1 to insert a student data, input 2 to search a student data,\ninput 3 to save all students data, input 4 to printf all, input 0 to exit!\n" void main() {struct student *p,*k,*f; int t; printf("input students'number(Tab)name(Tab)score1(Tab)score2(Tab)score(Enter)\n"); printf("and input 0 0 0 0 0 to end input!\n"); p=readin(); if(n!=1) k=taxis(p); f=k; printf(ONE); scanf("%d", while(t!=0) {if(t==1||t==2||t==3||t==4) {if(t==1)f=insert(f); if(t==2)search(f); if(t==3)save(f); if(t==4)show(f); } else printf("error!\n"); scanf("%d", } getch(); exit(0); 记住 使用TC 打卡.C文件
2008-07-07
求一个C语言计算器
推荐内容
求一个C语言计算器
求一个计算器 假设变量为 A B C D
公式 (A-B)/(C-D)*40+60
只用输入4个变量 按ENTER就能出来结果
10来自匿名用户的提问
回答
最佳答案
#include stdio.h
main()
{
int A,B,C,D;
printf("ABCD的值");
scanf("%d",
scanf("%d",
scanf("%d",
scanf("%d",
printf("(A-B)/(C-D)*40+60 = %d",(A-B)/(C-D)*40+60);
}
2011-02-13
5
其他回答2条回答
无所不能
#include stdio.h
#include conio.h
main()
{
int a,b,c,d,e;
scanf("%d%d%d%d", a, b, c,
e=(a-b)/(c-d)*40+60;
printf("%d\n",e);
getch();
}
2011-02-13
抢首赞
影子
#include stdio.h
int main()
{
double a,b,c,d,n;
printf("请输入4个数!\n");
scanf("%lf%lf%lf%lf", a, b, c,
n = (a-b)/(c-d)*40+60;
printf("结果是%.1lf",n);
}
2011-02-13
本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
0条评论