麻烦帮我看一下我用if语句编写的四则运算 20
#include"stdio.h"voidmain(){inta,b,c;charch;printf("Pleaseinputtwonumber:",a,b);scanf...
#include "stdio.h"
void main()
{
int a,b,c;
char ch;
printf("Please input two number:",a,b);
scanf("%d,%d",&a,&b);
printf("Please input an operator:",ch);
scanf("%c",&ch);
{
if(ch='+')
c=a+b;
printf("%d",c);
else if(ch='-')
c=a+b;
printf("%d",c);
else if(ch='/')
c=a+b;
printf("%d",c);
else (ch='*')
c=a+b;
printf("%d",c);
}
} 展开
void main()
{
int a,b,c;
char ch;
printf("Please input two number:",a,b);
scanf("%d,%d",&a,&b);
printf("Please input an operator:",ch);
scanf("%c",&ch);
{
if(ch='+')
c=a+b;
printf("%d",c);
else if(ch='-')
c=a+b;
printf("%d",c);
else if(ch='/')
c=a+b;
printf("%d",c);
else (ch='*')
c=a+b;
printf("%d",c);
}
} 展开
展开全部
1.你的最前面的两个printf函数,因为你没有引用某个变量或常数,改为printf("please enter tow numbs");后面那个也一样的。。。
2.后面if语句的大括号{},多余,不过应该也没事!
2.后面if语句的大括号{},多余,不过应该也没事!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include "stdio.h"
void main()
{
int a,b,c;
char ch;
printf("Please input two number:a b\n");
scanf("%d %d",&a,&b);
getchar();
printf("Please input an operator ch:\n");
scanf("%c",&ch);
if(ch=='+') c=a+b;
else if(ch=='-') c=a-b;
else if(ch=='/') c=a/b;
else if(ch=='*') c=a*b;
printf("\n%d\n",c);
}
void main()
{
int a,b,c;
char ch;
printf("Please input two number:a b\n");
scanf("%d %d",&a,&b);
getchar();
printf("Please input an operator ch:\n");
scanf("%c",&ch);
if(ch=='+') c=a+b;
else if(ch=='-') c=a-b;
else if(ch=='/') c=a/b;
else if(ch=='*') c=a*b;
printf("\n%d\n",c);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-04-19
展开全部
自己看,哪点错了!!
#include "stdio.h"
void main(){
int a,b,c;
char ch;
printf("Please input two number:");
scanf("%d,%d",&a,&b);
getchar();
printf("Please input an operator:\n");
scanf("%c",&ch);
if(ch=='+'){
c=a+b;
printf("%d",c);
}
else if(ch=='-') {
c=a-b;
printf("%d",c);
}
else if(ch=='/'){
c=a/b;
printf("%d",c);
}
else if(ch=='*'){
c=a*b;
printf("%d",c);
}
system("pause");
}
#include "stdio.h"
void main(){
int a,b,c;
char ch;
printf("Please input two number:");
scanf("%d,%d",&a,&b);
getchar();
printf("Please input an operator:\n");
scanf("%c",&ch);
if(ch=='+'){
c=a+b;
printf("%d",c);
}
else if(ch=='-') {
c=a-b;
printf("%d",c);
}
else if(ch=='/'){
c=a/b;
printf("%d",c);
}
else if(ch=='*'){
c=a*b;
printf("%d",c);
}
system("pause");
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |