Skip to content

Instantly share code, notes, and snippets.

@FloydHsiu
Last active October 31, 2016 04:13
Show Gist options
  • Save FloydHsiu/94c5c029d8e304820372661b8e402d4f to your computer and use it in GitHub Desktop.
Save FloydHsiu/94c5c029d8e304820372661b8e402d4f to your computer and use it in GitHub Desktop.
int main()
{
int N;
double input;
printf("學號後五碼:30023\n");
printf("Enter a number:");
scanf("%lf",&N); //讀double要用%lf
fflush(stdin);
if(N>=-50 && N<=50)
{
printf("輸入運算符號:");
scanf("%c",&input);
switch(input)
{
case'+':
printf("30023+%lf=%lf",N,30023+N);
break;
case'-':
printf("30023-%lf=%lf",N,30023-N);
break;
case'*':
printf("30023*%lf=%lf",N,30023*N);
break;
case'/':
printf("30023/%lf=%lf",N,30023/N);
break;
}
}
else printf("error");
printf("\n");
system("pause");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment