#include<stdio.h>
int main()
{
int choice;
printf("Enter 1 for Programmers Name and ID\n");
printf("Enter 2 to Perform Integer Operation\n");
printf("Enter 3 to Perform Floating Point Operation\n");
scanf("%d", &choice);
system("CLS");
if (choice == 1)
printf("Connor \n000000000\n");
else if (choice == 2)
{
char c;
int num1, num2;
printf("Enter operator:");
scanf("%c", &c);
getchar();
printf("Enter two integer's :");
scanf("%d %d", &num1, &num2);
switch (c)
{
case '+':
printf("%d + %d = %d", num1, num2, num1 + num2);
break;
case '-':
printf("%d - %d = %d", num1, num2, num1 - num2);
break;
case '*':
printf("%d * %d = %d", num1, num2, num1*num2);
break;
case '/':
printf("%d/%d = %d", num1, num2, num1/num2);
break;
default:
printf("The value of c = '%c'\n");
system("pause");
return(0);
}
}
else if (choice == 3)
printf("Enter two \n");
system("pause");
return(0);
}
我需要一點幫助,找出這個代碼的操作部分的一個小問題.......一切正常,因爲可以放在操作符和整數,但我沒有得到交換機的輸出。開關盒程序不給出輸出
嘗試把'在每個的printf的端\ N'。 – user3386109 2014-10-06 23:10:21
@ user3386109他沒有得到任何輸出......所以\ n不是問題 – Steve 2014-10-06 23:11:01
沒有讀過它,但添加一個'default'子句並打印出'c'的值將是一個好的開始的調試。 – 2014-10-06 23:11:59