{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

&aring;&reg;ž&eacute;&ordf;Œ

&aring;&reg;ž&eacute;&ordf;Œ - s...

This preview shows pages 1–14. Sign up to view the full content.

s _2 main() {int num,price,total; scanf("%d",&num); if (num<10) price=25; if (num>=10&&num<50) price=24; if (num>=50&&num<100) price =22; if (num>=100) price=20; total=price*num; printf("\ntotal cost=%d\n",total); } if (num<10) price=25; else if (num<50) price=24; else if (num<100) price =22; else price=20; if (num<50) if (num<10) price=25; else price=24; else if (num<100) price=22; else price=20;

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
s _2_2 main() {int num,i,price,total; scanf("%d",&num); if (num>=100) i=10; else i=num/10; switch (i) {case 0: price=25;break; case 1: case 2: case 3: case 4: price=24;break; case 5: case 6: case 7: case 8: case 9: price=22;break; case 10: price=20;break; } total=price*num; printf("\ntotal cost= %d\n",total);}
s _3 main() {int i; float x,y; for(i=0;i<=3;i++) {scanf("%f",&x); if (x<1) y=x*x; if (x>=1&&x<10) y=3*x-2; if (x>=10) y=x*x*(x-10)+28; printf("y=%-10.3f\n",y); } }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
s _4 main() {long num; int i,a,b,c,d,e; scanf("%ld",&num); if (num>9999) i=5; else if (num>999) i=4; else if (num>99) i=3; else if (num>9) i=2; else i=1; switch (i) {case 5: a=num/10000; printf("%d,",a); num=num%10000; case 4: b=num/1000; printf("%d,",b); num=num%1000; case 3: c=num/100; printf("%d,",c); num=num%100; case 2: d=num/10; printf("%d,",d); num=num%10; case 1: e=num; printf("%d\n",e);} switch (i) {case 5: printf(” %d\r",a); case 4: printf(" %d,\r",b); case 3: printf(" %d,\r",c); case 2: printf(" %d,\r",d); case 1: printf("%d,\n",e); } } switch (num) {case (num>9999): i=5;break; case (num>999&&num<10000):i=4;break; case (num>99&&num<1000): i=3;break; case (num>9&&num<100): i=2;break; case (num>=0&&num<10): i=1;break; }
s _1 main() {float e=1,t; int i; long m=1; i=1; do {m=m*i; t=1.0/m; e=e+t; i=i+1; } while (t>1e-7); printf("e=%f\n", e); } main() {float e=1,t; int i; long m=1; i=1;t=1; while (t>1e-7) {m=m*i; t=1.0/m; e=e+t; i=i+1; } printf("e=%f\n", e); } main() {float e=1,t; int i; long m=1; for(i=1,t=1;t>1e-7; i++) {m=m*i; t=1.0/m; e=e+t; } printf("e=%f\n",e); }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
s _2 main() {int i,a,b,c; for (i=100;i<1000;i++) {a=i/100;b=i%100/10;c=i%10; if (i%5==0 && a+b+c == 9) printf("%d,",i); } } if (i%5==0&&i/100+i%100/10+i%10==9) printf(“%d”,i);
s _3 #include "math.h" main() {int i,j,k,m,l,h; for (i=96;i<=100;i=i+2) {l=i/2; for (j=2;j<l;j++) {k=sqrt(j); for (m=2;m<=k;m++) if (j%m==0) break; if (m>=k+1) {h=i-j; k=sqrt(h); for (m=2;m<=k;m++) if (h%m==0) break; if (m>=k+1) {printf("%d=%d+%d\n", i,j,h); break;} } } } } #include "math.h" main() {int i,m,n,k1,k2,h1,h2; for (i=96;i<=100;i=i+2) {for (m=2;m<i;m++) {n=i-m; k1=sqrt(n);k2=sqrt(n); for (h1=2;h1<=k1;h1++) if (m%h1==0) break; for (h2=2;h2<=k2;h2++) if (n%h2==0) break; if (h1>=k1+1&&h2>=k2+1) {printf("%d=%d+%d\n", i,m,n); break;} } } }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
s _4 main() {int a=0,b=0,i; for(i=1;i<=100;i=i+2) {a=a+i;b=b+i+1;} printf("odd-sum=%d,even sum=%d\n",a,b); }
s _4 #include "stdio.h" main() {int s,n=0,m=0,b=0; char c1,c2; while ((c1=getchar())!='Q') if (c1!='\n') {if (c1>='0' && c1<='9') if (b==0) n=n*10+c1-'0'; else m=m*10+c1-'0'; else {c2=c1; b=1;} } else {switch(c2) {case '-':s=n-m; break; case '+':s=n+m; break; case '*':s=n*m; break; case '/':s=n/m; break; } printf("result=%d\n",s); n=0;m=0;b=0; } }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
s _1 main() {static int a[10]={0,3,4,6,8,10}; int i,j,k,t,x,end; end=5; for(i=1;i<5;i++) {scanf("%d",&x); if (x>=a[end]) {a[end+1]=x; end++; } else for(j=0;j<=end;j++) if (x<a[j]) { for (k=j;k<=end;k++) {t=a[k]; a[k]=x; x=t; } end++; break; } } for (j=0;j<10;j++) printf("%d ",a[j]); printf("\n"); } for(k=end+1;k>j;k--) a[k]=a[k-1]; a[j]=x; if(j>=end+1) {a[end]=x; end++;}
s _2 main() {static int a[4][4]={{3,6,4,6},{8,3,1,3}, {4,7,1,2},{2,9,5,3}}; int i,sum=0; for (i=0;i<4;i++) sum=sum+a[0][i]+a[3][i]; for (i=1;i<3;i++) sum=sum+a[i][0]+a[i][3]; printf("sum=%d\n",sum); }

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
main() {static float score[5][4]={{76,80,90},{90,65,77},{63,55,70}, {90,92,97},{73,69,82}}; char name[5][6]={"stud1","stud2","stud3", "stud4","stud5"}; int i,j,k; char ct; float sum,t; for (i=0;i<5;i++) {sum=0.0; for (j=0;j<3;j++) sum=sum+score[i][j]; score[i][3]=sum/3; } 2 _3
for (j=0;j<=3;j++)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}