参考解答:
#include<stdio.h> int main() { int n,i,r; int a,b; freopen("input.txt","r",stdin); scanf("%d",&n); for(i=0; i<n; i++) { scanf("%d%d",&a,&b); while(b!=0) { r=a%b; a=b; b=r; } printf("%d\n",a); } return 0; }
参考解答:
#include<stdio.h> int main() { int n,a; freopen("input.txt","r",stdin); while(scanf("%d",&n) != EOF) { a=n; while(a>0) { printf("%d ",a%10); a=a/10; } printf("\n"); } return 0; }
参考解答:
#include<stdio.h> int main() { int score, a=0, b=0, c=0, d=0; freopen("input.txt","r",stdin); scanf("%d",&score); while(score>=0&&score<=10) { if(score>=9) a++; else if(score>=7) b++; else if(score>=5) c++; else d++; scanf("%d",&score); } printf("A:%d\n",a); printf("B:%d\n",b); printf("C:%d\n",c); printf("D:%d\n",d); return 0; } 解2: #include<stdio.h> int main() { int score, a=0, b=0, c=0, d=0; freopen("input.txt","r",stdin); while(scanf("%d",&score)&&(score>=0&&score<=10)) { if(score>=9) a++; else if(score>=7) b++; else if(score>=5) c++; else d++; } printf("A:%d\n",a); printf("B:%d\n",b); printf("C:%d\n",c); printf("D:%d\n",d); return 0; }