#include <stdio.h>
int main()
{
int num1,num2;
char op;
float ans;
scanf("%d %c %d", &num1 ,&op ,&num2);
if(op == '+')
{
ans = num1 + num2;
}
else if(op == '-')
{
ans = num1 - num2;
}
else if(op == '*')
{
ans = num1 * num2;
}
else if(op == '/')
{
ans = (float)num1 / num2;
}
printf("ans: %f\n",ans);
return 0;
}
---------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
int main()
{
int score;
char grade;
scanf("%d",&score);
if(score>=90 && score<=100)
{
printf("grade = A\n");
}
else if(score>=80 && score<90)
{
printf("grade = B\n");
}
else if(score>=70 && score<80)
{
printf("grade = C\n");
}
else if(score>=60 && score<70)
{
printf("grade = D\n");
}
else
{
printf("grade = E\n");
}
}
沒有留言:
張貼留言