#include<stdio.h> int main() { char c; scanf("%c",&c); if('a'<=c&&c<='z') printf("%c\n",char(c-32)); else if('A'<=c&&c<='Z') printf("%c\n",char(c+32)); else printf("what you input is not a letter! "); return 0; }
第二题的: #include<stdio.h> int main() { int x,y; printf("Please input your number x:\n"); scanf("%d",&x); if(x>-1) y=2*x; else if(x<-1) y=4+x; else y=3; printf("%d",y);
return 0; }
第三题: #include<stdio.h> int main() { int n; printf("Please input a integer number:\n"); scanf("%d",&n); (n%2==0)?(printf("%d is Even\n",n)):(printf("%d is Odd\n",n)); return 0; }