https://blog.csdn.net/fjinhao/article/details/46853171
#include
int main()
{
int A,B;
scanf("%d %d",&A,&B);
printf("%d + %d = %d\n",A,B,A+B);
printf("%d - %d = %d\n",A,B,A-B);
printf("%d * %d = %d\n",A,B,A*B);
printf("%d / %d = %d\n",A,B,A/B);
return 0;
}
#include
int main()
{
int cm;
int foot,inch;
scanf("%d",&cm);
foot=cm/30.48;
inch=(cm/30.48-foot)*12;
printf("%d %d\n",foot,inch);
return 0;
}
#include
int main()
{
int all,hour,minute,time;
scanf("%d %d",&all,&time);
hour=all/100;
minute=all%100;
hour=(hour*60+minute+time)/60;
minute=(hour*60+minute+time)%60;
all=hour*100+minute;
printf("%d\n",all);
return 0;
}
#include
int main()
{
int before,after;
scanf("%d",&before);
after=before%10*100+before/10%10*10+before/100*1;
printf("%d\n",after);
return 0;
}
#include
int main()
{
int wrong,right,center1,center2;
scanf("%d",&wrong);
center1=wrong/16;
center2=wrong%16;
right=(center1+center2/10)*10+center2%10;
printf("%d\n",right);
return 0;
}
#include
int main()
{
int speed;
scanf("%d",&speed);
if(speed>60)
{
printf("Speed: %d - Speeding\n",speed);
}
else
{
printf("Speed: %d - OK\n",speed);
}
return 0;
}
#include
int main()
{
int N;
scanf("%d",&N);
if((N%5<=3)&&(N%5>0))
{
printf("Fishing in day %d\n",N);
}
else
{
printf("Drying in day %d\n",N);
}
return 0;
}
#include
int main()
{
int x,y,z;
scanf("%d %d %d",&x,&y,&z);
if(x==y)
{
printf("C\n");
}
else
{
if(x==z)
{
printf("B\n");
}
else
{
printf("A\n");
}
}
return 0;
}
#include
int main()
{
int hour,minute;
scanf("%d:%d",&hour,&minute);
if(hour<12)
{
printf("%d:%d AM\n",hour,minute);
}
else if(hour==12)
{
printf("%d:%d PM\n",hour,minute);
}
else
{
printf("%d:%d PM\n",hour-12,minute);
}
return 0;
}
#include
int main()
{
int score;
scanf("%d",&score);
switch(score/10)
{
case 9:
printf("A\n");break;
case 8:
printf("B\n");break;
case 7:
printf("C\n");break;
case 6:
printf("D\n");break;
default:
printf("E\n");
}
return 0;
}s
#include
int main()
{
int A;
int i,j,k,count=0;
int result;
scanf("%d",&A);
for(i=A;i<A+4;i++)
{
for(j=A;j<A+4;j++)
{
if(j==i)
{
continue;
}
for(k=A;k<A+4;k++)
{
if(k==j||k==i)
{
continue;
}
result=i*100+j*10+k;
printf("%d",result);
count++;
if(count%6!=0)
{
printf(" ");
}
else
{
printf("\n");
}
}
}
}
return 0;
}
#include
#include
int main()
{
long N,min,max,x,y,num,sum;
scanf("%d",&N);
min=pow(10,N-1);
max=min*10;
for(num=min;num<max;num++)
{
sum=0;
x=num;
while(x>0)
{
y=x%10;
if(y!=0)
sum+=pow(y,N);
x/=10;
}
if(sum==num)
{
printf("%d\n",num);
}
}
return 0;
}
#include
#include
int main()
{
int N;
scanf("%d",&N);
for(int i=1;i<=N;i++)
{
for(int j=1;j<=i;j++)
{
printf("%d*%d=%-4d",j,i,j*i);
}
printf("\n");
}
return 0;
}
#include
#include
int main()
{
int M,N;
int count=0,sum=0,num;
int flag,i;
scanf("%d %d",&M,&N);
for(num=M;num<=N;num++)
{
flag=1;
if(num==1)
{
continue;
}
for(i=2;i<=sqrt(num);i++)
{
if(num%i==0)
{
flag=0;
break;
}
}
if(flag)
{
count++;
sum+=num;
}
}
printf("%d %d",count,sum);
return 0;
}
#include
#include
int main()
{
int num=rand()%100+1;
int N=rand()%100+1;
int compute,count=0;
int flag=0;
do
{
scanf("%d",&compute);
if(compute<0)
{
break;
}
if(compute<num)
{
printf("Too small\n");
count++;
}
else if(compute>num)
{
printf("Too big\n");
count++;
}
else
{
count++;
if(count==1)
{
printf("Bingo!\n");
}
else if(count<=3)
{
printf("Lucky You!\n");
}
else if(count<=N)
{
printf("Good Guess!\n");
}
else
{
flag=1;
break;
}
break;
}
if(count==N)
{
flag=1;
break;
}
}while(compute>0);
if(flag||compute<0)
{
printf("Game Over\n");
}
return 0;
}
#include
int main()
{
int N,count=1;
double sum;
int i=2,j=1,k=0;
sum=1.0*i/j;
scanf("%d",&N);
while(count<N)
{
count++;
k=i;
i=i+j;
j=k;
sum+=1.0*i/j;
}
printf("%.2f\n",sum);
return 0;
}
#include
int main()
{
int a,b,m,n,t;
scanf("%d/%d",&a,&b);
m=a;
n=b;
while(n>0)
{
t=m%n;
m=n;
n=t;
}
printf("%d/%d\n",a/m,b/m);
return 0;
}
#include
#include
int main()
{
int num;
scanf("%d",&num); //輸入num
if(num<0)
{
printf("fu ");
num=-num;
}
int x=num,count=0; //count表示num的位数
do
{
x=x/10;
count++;
}while(x>0);
x=num;
int n;
while(count>0)
{
count--;
n=x/pow(10,count);
x-=n*pow(10,count);
switch(n)
{
case 0:printf("ling");break;
case 1:printf("yi");break;
case 2:printf("er");break;
case 3:printf("san");break;
case 4:printf("si");break;
case 5:printf("wu");break;
case 6:printf("liu");break;
case 7:printf("qi");break;
case 8:printf("ba");break;
case 9:printf("jiu");break;
default:;
}
if(count)
{
printf(" ");
}
}
printf("\n");
return 0;
}
#include
#include
int main()
{
int a,n,sum=0,num=0;
scanf("%d %d",&a,&n);
for(int i=0;i<n;i++)
{
num+=a*pow(10,i);
sum+=num;
}
printf("%d\n",sum);
return 0;
}
#include
int main()
{
double a,b;
char c;
int d;
scanf("%lf %d %c %lf",&a,&d,&c,&b);
printf("%c %d %.2f %.2f",c,d,a,b);
return 0;
}
#include
int main()
{
int a,b,result,flag;
char c;
scanf("%d",&a);
scanf("%c",&c);
while(c!='=')
{
flag=0;
scanf("%d",&b);
if(c=='+')
{
result=a+b;
}
else if(c=='-')
{
result=a-b;
}
else if(c=='*')
{
result=a*b;
}
else if(c=='/')
{
if(b==0)
{
flag=1;
break;
}
else
{
result=a/b;
}
}
else if(c=='=')
{
break;
}
else
{
flag=1;
break;
}
a=result;
scanf("%c",&c);
}
if(flag)
{
printf("ERROR\n");
}
else
{
printf("%d\n",result);
}
return 0;
}
#include
int main()
{
int length='a'-'A';
char c;
do
{
scanf("%c",&c);
if(c>='a'&&c<='z')
{
c=c-length;
}
else if(c>='A'&&c<='Z')
{
c=c+length;
}
else if(c=='#')
{
break;
}
printf("%c",c);
}while(c!='#');
printf("\n");
return 0;
}
#include
int main()
{
char c;
int count=0;
int flag=0;
do
{
scanf("%c",&c);
if(c!=' '&&c!='.')
{
count++;
}
else
{
if(flag)
{
printf(" %d",count);
}
else
{
printf("%d",count);
flag=1;
}
count=0;
}
}while(c!='.');
printf("\n");
return 0;
}
#include
#include
void Print(int num);
int main()
{
char ch;
int num=0;
while((ch=getchar())!='\n'){
num+=ch-'0';
}
Print(num);
return 0;
}
void Print(int num){
int x=num,count=0; //count表示num的位数
do
{
x=x/10;
count++;
}while(x>0);
x=num;
int n;
while(count>0)
{
count--;
n=x/pow(10,count);
x-=n*pow(10,count);
switch(n)
{
case 0:printf("ling");break;
case 1:printf("yi");break;
case 2:printf("er");break;
case 3:printf("san");break;
case 4:printf("si");break;
case 5:printf("wu");break;
case 6:printf("liu");break;
case 7:printf("qi");break;
case 8:printf("ba");break;
case 9:printf("jiu");break;
default:;
}
if(count)
{
printf(" ");
}
}
printf("\n");
}
#include
#include
int main()
{
int num;
scanf("%d",&num);
int count1,count2,count3;
count1=num/100;
count2=num/10%10;
count3=num%10;
int count=count1;
while(count){
printf("B");
count--;
}
count=count2;
while(count){
printf("S");
count--;
}
count=1;
while(count<=count3){
printf("%d",count);
count++;
}
printf("\n");
return 0;
}
#include
int main()
{
int T;
scanf("%d",&T);
int count=1;
long A,B,C;
while(count<=T)
{
scanf("%ld %ld %ld",&A,&B,&C);
if(A+B>C)
{
printf("Case #%d: true\n",count);
}
else
{
printf("Case #%d: false\n",count);
}
count++;
}
return 0;
}
#include
#include
int main()
{
int M,N;
scanf("%d %d",&M,&N);
int count=0;
long num=2;
int flag;
int count1=0; //格式计数
while(count<N)
{
flag=1;
for(int i=2;i<=sqrt(num);i++) //判断num是否为素数
{
if(num%i==0)
{
flag=0;
break;
}
}
if(flag) //num是素数
{
count++; //记录num为第几个素数
if(count>=M)
{
printf("%d",num);
count1++;
if(count1<10)
{
printf(" ");
}
else
{
printf("\n");
count1=0;
}
}
}
num++;
}
return 0;
}
#include
const int MAX=20;
int main()
{
int N;
long X,a[MAX];
int i,flag=1;
scanf("%d %ld",&N,&X);
for(i=0;i<N;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<N;i++)
{
if(a[i]==X)
{
printf("%d\n",i);
flag=0;
break;
}
}
if(flag)
{
printf("Not Found\n");
}
return 0;
}
#include
const int MAX=1000;
int num[10]={0}; //存储每位数字出现的次数
void Operate(int x,int num[]); //统计个位数字
int main()
{
int N,x;
int max=num[0];
scanf("%d",&N);
for(int i=0;i<N;i++)
{
scanf("%d",&x);
Operate(x,num);
}
//求出num最大值
for(int j=1;j<10;j++)
{
if(num[j]>max)
{
max=num[j];
}
}
//输出
printf("%d:",max);
for(int k=0;k<10;k++)
{
if(num[k]==max)
{
printf(" %d",k);
}
}
printf("\n");
return 0;
}
void Operate(int x,int num[])
{
int i=0;
while(x)
{
i=x%10;
num[i]++;
x/=10;
}
}
#include
#define MAX 20
int main()
{
int a[MAX][MAX]={0};
int M,N;
scanf("%d %d",&M,&N);
int i,j;
int flag=1;
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=1;i<M-1;i++)
{
for(j=1;j<N-1;j++)
{
if((a[i][j]>a[i-1][j])&&(a[i][j]>a[i+1][j])&&(a[i][j]>a[i][j-1])&&(a[i][j]>a[i][j+1]))
{
flag=0;
printf("%d %d %d\n",a[i][j],i+1,j+1);
}
}
}
if(flag)
{
printf("None %d %d\n",M,N);
}
return 0;
}
#include
int main()
{
int num[10]={0};
for(int i=0;i<10;i++)
{
scanf("%d",&num[i]);
}
for(int j=1;j<10;j++) //输出最高位
{
if(num[j])
{
printf("%d",j);
num[j]--;
break;
}
}
for(int k=0;k<10;k++)
{
while(num[k])
{
printf("%d",k);
num[k]--;
}
}
printf("\n");
return 0;
}
#include
#include
#define MAX 80
int main()
{
char str[MAX];
char *p;
gets(str);
int length;
length=strlen(str);
p=str+length;
while(1)
{
if(p==str)
{
printf("%s\n",p);
break;
}
if(*p==' '&&*(p+1)!=' ')
{
*p='\0';
printf("%s ",p+1);
}
p--;
}
return 0;
}
#include
#include
#define MAX 80
int main()
{
char str[MAX];
int flag=0;
gets(str);
char c;
scanf("%c",&c);
char *p=NULL;
for(int k=0;k<strlen(str);k++)
{
if(c==str[k])
{
flag=1;
p=&str[k];
break;
}
}
if(flag)
{
printf("%s\n",p);
}
else
{
printf("Not found\n");
}
return 0;
}
#include
#include
#define MAX 80
int main()
{
char s1[MAX],s2[MAX];
gets(s1);
gets(s2);
int i;
while(1)
{
char *p=strstr(s1,s2);
if(p)
{
for(i=0;i<strlen(p)-strlen(s2);i++)
{
p[i]=p[strlen(s2)+i];
}
p[i]='\0';
}
else
{
printf("%s\n",s1);
break;
}
}
return 0;
}
#include
#include
#define MAX 80
int main()
{
char str[MAX];
gets(str);
int l=strlen(str);
for(int i=l-1;i>=0;i--)
{
printf("%c",str[i]);
}
printf("\n");
return 0;
}
#include
#include
#define MAX 100
int main()
{
char str[MAX];
gets(str);
int N,i,j;
scanf("%d",&N);
N%=strlen(str);
char temp[MAX];
strncpy(temp,str,N);
for(i=0;i<strlen(str)-N;i++)
{
str[i]=str[N+i];
}
for(j=i;j<strlen(str);j++)
{
str[j]=temp[j-strlen(str)+N];
}
puts(str);
return 0;
}
#include
#include
#define EPSILON 0.05
struct Vector{
double x;
double y;
};
int main()
{
Vector v1,v2,v3;
scanf("%lf %lf %lf %lf",&v1.x,&v1.y,&v2.x,&v2.y);
v3.x=v1.x+v2.x;
v3.y=v2.y+v2.y;
if(fabs(v3.x)<EPSILON)
{
v3.x=fabs(v3.x);
}
if(fabs(v3.y)<EPSILON)
{
v3.y=fabs(v3.y);
}
printf("(%.1lf, %.1lf)",v3.x,v3.y);
return 0;
}
#include
struct Info{
char name[10];
char birth[10];
char sex;
char tele[15];
char phone[15];
};
int main()
{
Info people[10];
int N,k;
scanf("%d",&N);
for(int i=0;i<N;i++)
{
scanf("%s %s %c %s %s",people[i].name,people[i].birth,&people[i].sex,people[i].tele,people[i].phone);
}
int K;
int found[10];
scanf("%d",&K);
for(int i=0;i<K;i++)
{
scanf("%d",&found[i]);
}
for(int j=0;j<K;j++)
{
if(found[j]<N&&found[j]>=0)
{
k=found[j];
printf("%s %s %s %c %s\n",people[k].name,people[k].tele,people[k].phone,people[k].sex,people[k].birth);
}
else
{
printf("Not Found\n");
}
}
return 0;
}