前言:唉,刚考完物理,只求30分T=T
字母个数统计
#include<stdio.h> #include <string.h> void main() { char x[1000]; int y,i,sum=0; gets(x); y=strlen(x); for(i=0;i<=y;i++) { if(x[i]>='a'&&x[i]<='z'||x[i]>='A'&&x[i]<='Z') sum++; } printf("%d\n",sum); }
#include<stdio.h> #include <string.h> void main() { char x[1000]; int y,i,sum=0; gets(x); y=strlen(x); for(i=0;i<=y;i++) { if(x[i]>='0'&&x[i]<='9') sum++; } printf("%d\n",sum); }
#include<stdio.h> #include <string.h> void main() { char x[1000]; int y,i,sum1=0,sum2=0,sum3=0,sum4=0; gets(x); y=strlen(x); for(i=0;i<y;i++) { if(x[i]>='a'&&x[i]<='z'||x[i]>='A'&&x[i]<='Z') sum1++; else if(x[i]>='0'&&x[i]<='9') sum2++; else if(x[i]==' ') sum3++; else sum4++; } printf("%d %d %d %d\n",sum1,sum2,sum3,sum4); }
#include <stdio.h> void main() { char c[1000],x; int y,i,l=0; gets(c); y=strlen(c); for(i=0;i<y;i++) { if(c[i]==c[i+1]) { x=c[i]; l++; break; } } while(l==1) { printf("%c\n",x); break; } while(l==0) { printf("No\n"); break; } }
#include<stdio.h> void main() { char x[1000]; int y=0; while(gets(x),strcmp(x,"@")) y++; printf("%d\n",y); }
#include <stdio.h> #include<string.h> int main() { int b,sum=0; char c[1000],ch; gets(c); scanf("%c",&ch); for(b=0;b<strlen(c);b++) { if(c[b]==ch) sum++; } printf("%d\n",sum); return 0; }
#include <stdio.h> void main() { char c[1000]; int i,y; gets(c); y=strlen(c); for(i=0;i<y;i++) { if(c[i]>='A'&&c[i]<='Z') { c[i]=c[i]+32; } else if(c[i]>='a'&&c[i]<='z') { c[i]=c[i]-32; } else { continue; } } puts(c); }
#include <stdio.h> void main() { int x; scanf("%d",&x); if(x>=60) printf("pass\n"); else printf("failure\n"); }
#include <stdio.h> void main() { int x; scanf("%d",&x); if(x>=80&&x<=100) printf("A\n"); else if(x<=79&&x>=60) printf("B\n"); else printf("C\n"); }
#include <stdio.h> void main() { int x; scanf("%d",&x); if(x>=90&&x<=100) printf("A\n"); else if(x>=80&&x<=89) printf("B\n"); else if(x>=70&&x<=79) printf("C\n"); else if(x>=60&&x<=69) printf("D\n"); else printf("E\n"); }
#include <stdio.h> void main() { int x,y; scanf("%d%d",&x,&y); if(x>y) printf("%d\n",x); else printf("%d\n",y); }
#include <stdio.h> void main() { int x,y; scanf("%d%d",&x,&y); if(x>y) printf("%d %d\n",y,x); else printf("%d %d\n",x,y); }
#include <stdio.h> void main() { char x,y; scanf("%c%c",&x,&y); if(x>y) printf("%c %c\n",y,x); else printf("%c %c\n",x,y); }
#include <stdio.h> void main() { int x,y,z,max=0; scanf("%d%d%d",&x,&y,&z); if(x>y&&x>z) max=x; else if(y>z&&y>x) max=y; else if(z>y&&z>x) max=z; printf("%d\n",max); }
#include <stdio.h> void main() { int x,y,z; scanf("%d%d%d",&x,&y,&z); if(x>y&&x>z&&y>z) {printf("%d %d %d\n",x,y,z);} if(x>y&&x>z&&z>y) {printf("%d %d %d\n",x,z,y);} if(y>x&&y>z&&z>x) {printf("%d %d %d\n",y,z,x);} if(y>x&&y>z&&x>z) {printf("%d %d %d\n",y,x,z);} if(z>x&&z>y&&x>y) {printf("%d %d %d\n",z,x,y);} if(z>x&&z>y&&y>x) {printf("%d %d %d\n",z,y,x);} }
#include <stdio.h> void main() { int x,y,z,i; scanf("%d%d",&x,&y); if((4*x-y)%2!=0) {printf("NO answer\n");} else {z=(4*x-y)/2; i=x-(4*x-y)/2; if(z<0||i<0) printf("NO answer\n"); else printf("%d %d\n",z,i);} }
#include <stdio.h> void main() { double x,y; scanf("%lf",&x); if(x<500) printf("%.2lf\n",x); else if(x>=500&&x<=999) { x=0.95*x; printf("%.2lf\n",x); } else if(x>=1000&&x<=2999) { x=0.9*x; printf("%.2lf\n",x); } else if(x>=3000&&x<=4999) { x=0.85*x; printf("%.2lf\n",x); } else if(x>=5000) { x=0.8*x; printf("%.2lf\n",x); } }
#include <stdio.h> void main() { int x; scanf("%d",&x); if(x>=30) printf("%.2lf\n",x*48.0); else printf("%.2lf\n",x*50.0); }
#include <stdio.h> void main() { double x; scanf("%lf",&x); if(x>=7.91&x<11.19) printf("1\n"); if(x>=11.19&&x<16.67) printf("2\n"); if(x>=16.67) printf("3\n"); }
#include <stdio.h> void main() { unsigned int x; scanf("%d",&x); if(x%5==0&&x%7==0) printf("yes\n"); else printf("no\n"); }
#include<stdio.h> void main() { unsigned int n,i; scanf("%d",&n); for(i=1;i<n;i++) { if(i%5==0&&i%7==0) printf("%d ",i); } printf("\n"); }
#include <stdio.h> void main() { int x; scanf("%d",&x); if((x%4==0)&&(x%100!=0)||(x%400==0)) {printf("yes\n");} else {printf("no\n");} }
#include <stdio.h> void main() { int x,y; scanf("%d%d",&x,&y); if((x%4==0)&&(x%100!=0)||(x%400==0)) { if(y==2) printf("29\n"); else if(y%2!=0&&y<8||y%2==0&&y>8||y==8) printf("31\n"); else printf("30\n"); } else { if(y==2) printf("28\n"); else if(y%2!=0&&y<8||y%2==0&&y>8||y==8) printf("31\n"); else printf("30\n"); } }
#include <stdio.h> void main() { int y0,m0,d0,y1,m1,d1,age; scanf("%d%d%d%d%d%d",&y0,&m0,&d0,&y1,&m1,&d1); age=y1-y0; if(m1<m0) age=age-1; else if(m1==m0) { if(d1<d0) age=age-1; } printf("%d\n",age); }
#include<stdio.h> void main() { int x,y,y1,z; scanf("%d%d",&x,&y); if(x%4==0&&x%100!=0||x%400==0) { if(y<=31) {y1=1; z=y;} else if(y>31&&y<=60) {y1=2; z=y-31;} else if(y>60&&y<=91) {y1=3; z=y-60;} else if(y>91&&y<=121) {y1=4; z=y-91;} else if(y>121&&y<=152) {y1=5; z=y-121;} else if(y>152&&y<=182) {y1=6; z=y-152;} else if(y>182&&y<=213) {y1=7; z=y-182;} else if(y>213&&y<=244) {y1=8; z=y-213;} else if(y>244&&y<=274) {y1=9; z=y-244;} else if(y>274&&y<=305) {y1=10; z=y-274;} else if(y>305&&y<=335) {y1=11; z=y-305;} else {y1=12; z=y-355;} } else { if(y<=31) {y1=1; z=y;} else if(y>31&&y<=59) {y1=2; z=y-31;} else if(y>59&&y<=90) {y1=3; z=y-59;} else if(y>90&&y<=120) {y1=4; z=y-90;} else if(y>120&&y<=151) {y1=5; z=y-120;} else if(y>151&&y<=181) {y1=6; z=y-151;} else if(y>181&&y<=212) {y1=7; z=y-181;} else if(y>212&&y<=243) {y1=8; z=y-212;} else if(y>243&&y<=273) {y1=9; z=y-243;} else if(y>273&&y<=304) {y1=10; z=y-273;} else if(y>304&&y<=334) {y1=11; z=y-304;} else {y1=12; z=y-334;} } printf("%d-%d-%d\n",x,y1,z); }
#include<stdio.h> void main() { int a,b,y; scanf("%d%d",&a,&b); y=a*a+b*b; if(y>100) printf("%d\n",y/100); else printf("%d\n",y); }
#include <stdio.h> void main() { int x; scanf("%d",&x); if(x<=40) printf("%d\n",30*x); else printf("%.0lf\n",30*40+(x-40)*1.5*30); }
#include <stdio.h> void main() { int x; scanf("%d",&x); if(x<=10000) printf("%.2lf\n",x*0.05+1500); else if(x>10000&&x<=50000) printf("%.2lf\n",(x-10000)*0.03+2000); else printf("%.2lf\n",(x-50000)*0.02+3200); }
#include <stdio.h> void main() { long int i,j; double s; scanf("%ld",&i); j=i-3000; if(j<=0) s=0; else if(j<=1500) s=j*0.05; else if(j<=4500) s=j*0.1-75; else if(j<=9000) s=j*0.2-75-450; else if(j<=35000) s=j*0.25-75-450-9000*0.05; else if(j<=55000) s=j*0.3-75-450-9000*0.05-35000*0.05; else if(j<=80000) s=j*0.35-75-450-9000*0.05-35000*0.05-55000*0.05; else s=j*0.45-75-450-9000*0.05-35000*0.05-55000*0.05-80000*0.1; printf("%.2lf\n",s); }
#include<stdio.h> void main() { int x,y,z; scanf("%d%d",&x,&y); if(x<=0) z=0; else if(x!=0&&x<=3) z=10; else if(x>3&&x<=10) z=10+(x-3)*2; else z=24+(x-10)*3; if(y%5!=0) z=z+(y/5+1)*2; else z=z+(y/5)*2; printf("%d\n",z); }
#include<stdio.h> #include <math.h> void main() { float a,b,c,x1,x2,y; scanf("%f%f%f",&a,&b,&c); y=b*b-4*a*c; if(y>0) { x1=(-b+sqrt(y))/(2*a); x2=(-b-sqrt(y))/(2*a); if(x1>x2) printf("%.2f %.2f\n",x1,x2); else printf("%.2f %.2f\n",x2,x1); } else { x1=(-b)/(2*a); printf("%.2f\n",x1); } }
#include <stdio.h> #include <math.h> void main() { double x,y,a,b,c,d; scanf("%lf%lf",&x,&y); a=sqrt((x-2)*(x-2)+(y-2)*(y-2)); b=sqrt((x-2)*(x-2)+(y+2)*(y+2)); c=sqrt((x+2)*(x+2)+(y-2)*(y-2)); d=sqrt((x+2)*(x+2)+(y+2)*(y+2)); if(a<=0.5||b<=0.5||c<=0.5||d<=0.5) printf("50\n"); else printf("0\n"); }
#include <stdio.h> void main() { int x; scanf("%d",&x); switch(x) { case(1):printf("One\n");break; case(2):printf("Two\n");break; case(3):printf("Three\n");break; case(4):printf("Four\n");break; case(5):printf("Five\n");break; case(6):printf("Six\n");break; case(7):printf("Seven\n");break; case(8):printf("Eight\n");break; case(9):printf("Nine\n");break; case(10):printf("Ten\n");break; default:printf("Error\n");break; } }
#include <stdio.h> void main() { float x,y; char z; scanf("%f%c%f",&x,&z,&y); switch(z) { case('+'):printf("%.2f\n",x+y);break; case('-'):printf("%.2f\n",x-y);break; case('*'):printf("%.2f\n",x*y);break; case('/'):printf("%.2f\n",x/y);break; } }
#include <iostream> #include <iomanip> using namespace std; int main() { int maxn; while(cin>>maxn) { int i=2,day=1,sum=2; while(sum<=maxn) { i*=2; day++; sum+=i; } cout<<fixed<<setprecision(2)<<"Average="<<sum*1.2/day<<endl; } return 0; }
#include <stdio.h> void main() { int x,i; scanf("%d",&x); for(i=1;i<=x;i++) { printf("%d\n",i); } }
#include <stdio.h> void main() { char c[3]; gets(c); puts(c); }
#include <stdio.h> void main() { char c[100]; gets(c); puts(c); }
#include<stdio.h> void main() { int x,y,i,l=0; scanf("%d%d",&x,&y); i=x; while(i<=y) { if((i%3)!=0) { printf("%d",i); i++; l++; if(l!=5) printf(" "); if(l==5) { printf("\n"); l=0; } } else i++; } }
#include <stdio.h> void main() { int x,i,sum=0; scanf("%d",&x); for(i=0;i<=x;i++) { sum=sum+i; } printf("%d\n",sum); }
#include <stdio.h> #include <math.h> void main() { int x,i,d,sum=0; scanf("%d",&x); d=0; for(i=0;i<x;i++) { d=abs(d)+1; if(d%2==0) d=d*(-1); sum+=d; } printf("%d\n",sum); }
#include <stdio.h> void main() { int x,y; scanf("%d",&x); if(x%2!=0) { y=(1+x)*(x+1)/4; printf("%d\n",y); } }
#include <stdio.h> void main() { int x,y=0,z=0,i; scanf("%d",&x); for(i=1;i<=x;i++) { y+=i; z=z+y; } printf("%d\n",z); }
#include <stdio.h> void main() { int x,y=0,z,i; scanf("%d",&x); for (i=1;i<=x;i++) { z=i*i; y+=z; } printf("%d\n",y); }
#include <stdio.h> void main() { int x,y,z=0,i; scanf("%d",&x); for(i=1;i<=x;i++) { y=i*(i+1); z+=y; } printf("%d\n",z); }
#include<stdio.h> #include <math.h> void main() { int x,y,sum=0,i; scanf("%d",&x); for(i=1;i<=x;i++) { y=pow(i,3); sum+=y; } printf("%d\n",sum); }
#include<stdio.h> #include <math.h> void main() { int a,b,y=0,z=0,sum=0,i; double x=0; scanf("%d%d",&a,&b); for(i=0;i<a;i++) { x=pow(10,i); y=b*x; z+=y; sum+=z; } printf("%d\n",sum); }
#include <stdio.h> void main() { double x,i,sum=0,z=0; scanf("%lf",&x); for(i=1.0;i<=x;i++) { z=1/i; sum+=z; } printf("%.6lf\n",sum); }
#include <stdio.h> void main() { int x,i,y=1; double sum=0,z=0; scanf("%d",&x); for(i=1;i<=x;i++) { z=1.0/y; sum+=z; y+=2; } printf("%.2lf\n",sum); }
#include <stdio.h> void main() { int x,i,y=1; double sum=0,z=0; scanf("%d",&x); for(i=1;i<=x;i++) { z=1.0/y; sum+=z; y+=2; } printf("%.2lf\n",sum); }