kbys.net
当前位置:首页 >> C语言 要求编写一个简单计算器的程序 >>

C语言 要求编写一个简单计算器的程序

#includevoid main() { float x,y,z; char c; scanf("%f%c%f",&x,&c,&y); switch ( c ) { case '+': z=x+y; break; case '-': z=x-y; break; case '*': z=x*y; break; case '/': z=( y==0 )?(0):(x/y); break; default: z=0; break; } printf("%...

#include #include main() { float a,b; char c; printf("please input the expression:"); scanf("%f%c%f",&a,&c,&b); swich(c) { case'+': printf("%f",a+b); case'-': printf("%f",a-b); case'*': printf("%f",a*b); case'/': if(b==0) print...

如果我的回答你还满意记得选个满意答案哦#include void main() { float a,b; char c; printf("请输入两个操作数:"); scanf("%f",&a); scanf("%f",&b); getchar(); printf("请选择操作运算:"); scanf("%c",&c); switch(c) { case '+': printf("结...

#include void main() { float a,b; char d; printf("请输入两个数a,b:"); scanf("%f,%f"&a,&b); printf("请输入符号d"); scanf("%c",d); switch(d) { case'+':printf("%f\n,a+b);break; case'-':printf("%f\n,a-b);break; case'*':printf("%...

#include int main(){ char judge,oper; double a, b,result; printf("是否需要计算,输入Y或y表示需要,输入N或n表示不需要\n"); judge = getchar(); while (judge != 'N' && judge != 'n') { if (judge == 'Y' || judge == 'y') { printf("请...

#include int main() { char c = 'Y'; float x,y,z; char operate; while(c=='Y' || c=='y') { printf("please enter number1:"); scanf("%f",&x); printf("please enter operate:"); getchar(); scanf("%c",&operate); printf("please enter nu...

int x,y,z; char op; scanf("%d%c%d,&x,&op,&y"); switch(op) { case '+':z=x+y; printf("%d+%d=%d",x,y,z);break; case '-':z=x-y; printf("%d-%d=%d",x,y,z);break; case '*':z=x*y; printf("%d*%d=%d",x,y,z);break; case '/':z=x/y; printf(...

#include int jisuan(int a,int b,char fu){if(fu=='+') return a+b;if(fu=='-') return a-b;if(fu=='*') return a*b;if(fu=='/') return a/b;}int fun(char *ss,int n){int i,flag=0;if(n==1) return ss[0]-'0';for(i=0;i

#include int main() { double num1 = 0; //输入1 double num2 = 0; //输入2 char ch; //操作 double ret = 0; //结果 printf( "输入第一个数:" ); scanf( "%lf", &num1 ); printf( "输入第二个数:" ); scanf( "%lf", &num2 ); printf( "操作[+ ...

网站首页 | 网站地图
All rights reserved Powered by www.kbys.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com