#include <stdio.h>
#include <conio.h>
void main()
{
int i,j;
char s;
printf("請輸入整數1:");
scanf("%d",&i);
printf("請輸入整數2:");
scanf("%d",&j);
printf("請輸入運算子號:");
scanf(" %c",&s);
switch(s)
case "+":printf("\n加:%d+%d=%d",i,j,i+j);break;
case "-":printf("\n減:%d-%d=%d",i,j,i-j);break;
case "*":printf("\n乘:%d*%d=%d",i,j,i*j);break;
case "/":printf("\n除:%d/%d=%d",i,j,i/j);break;
}
getch();
#include <stdio.h>
#include <conio.h>
void main()
{
int i,j;
char s;
printf("請輸入整數1:");
scanf("%d",&i);
printf("請輸入整數2:");
scanf("%d",&j);
printf("請輸入運算子號:");
scanf(" %c",&s);
switch(s)
{
case "+":printf("\n加:%d+%d=%d",i,j,i+j);break;
case "-":printf("\n減:%d-%d=%d",i,j,i-j);break;
case "*":printf("\n乘:%d*%d=%d",i,j,i*j);break;
case "/":printf("\n除:%d/%d=%d",i,j,i/j);break;
}
getch();
}