#include<stdio.h>
#include<iostream>
using namespace std;
#define maxn 105
int a[maxn];
int main()
{
int x,n=0;
while(scanf("%d",&x)==1)
a[n++] = x;
for(int i=n-1;i >= 0;i--)
printf("%d ",a[i]);
printf("%d\n",a[0]);
return 0;
}
#include<stdio.h>
#include<string.h>
#define maxn 1000+10
int a[maxn];
int main()
{
int n,k,first=1;
memset(a,0,sizeof(a));
scanf("%d%d", &n,&k);
for(int i=1;i<=k;i++)
for(int j=1; j<=n;j++)
if(j%i==0) a[j]=!a[j];
for(int i=1;i<=n;i++)
if(a[i]){
if(first) first=0;else printf(" "); printf("%d",i);
}
printf("\n");
return 0;
}
#include<stdio.h>
#include<string.h>
#define maxn 20
int a[maxn][maxn];
int main()
{
int n,x,y,tot=0;
scanf("%d",&n);
memset(a,0,sizeof(a));
tot=a[x=0][y=n-1]=1;
while(tot<n*n){
while(x+1<n && !a[++x][y]) a[++x][y]=++tot;
while(y-1>=0 && !a[x][y-1]) a[x][--y]=++tot;
while(x-1>=0 && !a[x-1][y]) a[--x][y]=++tot;
while(y+1<n && !a[x][++y]) a[x][++y]=++tot;
}
for(int x=0;x<n;x++)
{
for(int y=0;y<n;y++)
printf("%5d ",a[x][y]);
printf("\n");
}
return 0;
}
/*
1. 不可以直接使用scantf, 遇到空格或者tab会停止
2. getchar
*/
int main()
{
int c,q=1;
while((c==getchar())!=EOF) //eof是文件结尾 eof=-1
{
if(c == ‘”’)
{
printf("%s",q ? ‘“’’ : ‘”’);q=!q;
}
else printf("%c",c);
}
return 0;
}
#include <stdio.h>
char s[] = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;‘ZXCVBNM,./";
int main()
{
int i, c;
while((c = getchar()) != EOF)
{
for(i = 1; s[i] && s[i] != c; i++);
if(s[i]) putchar(s[i-1]);
else putchar(c);
}
return 0;
}
#include<stdio.h>
#include<string.h>
#include<ctype.h>
const char* rev="A 3 HIL JM O 2TUVWXY51SE Z 8";
const char* msg[]={"not a palinadrome"," a regular palindromw","a mirrored string", "a mirrored palindrome"};
char r(char ch)
{
if(isalpha(ch))
return rev[ch-'A'];
return rev[ch-'0'+25];
}
int main()
{
char s[30];
while(scanf("%s",s)==1){
int len=strlen(s);
int p=1,m=1;
for(int i=0;i<(len+1)/2;i++){
if(s[i]!=s[len-1-i])
p=0;
if(r(s[i])!=s[len-1-i])
m=0;
}
printf("%s -- is %s .\n\n", s,msg[m*2+p]);
}
return 0;
}
#include<stdio.h>
#define maxn 1000+10
int main()
{
int n,a[maxn],b[maxn];
int kase=0;
while(scanf("%d",&n)==1 && n)
{
printf("Game %d: \n",++kase);
for(int i=0;i<n;i++) scanf("%d",&a[i]);
for(;;)
{
int A=0,B=0;
for(int i=0;i<n;i++)
{
scanf("%d", &b[i]);
if(a[i] == b[i]) A++;
}
if(b[0]==0) break;
for(int d=1;d<=9;d++){
int c1=0,c2=0;
for(int i=0;i<n;i++)
{
if(a[i] ==d) c1++;
if(b[i]==d) c2++;
}
if(c1<c2) B+=c1;else B+=c2;
}
printf(" (%d,%d)\n",A,B-A);
}
}
return 0;
}
#include<stdio.h>
#include<string.h>
#define maxn 10000+5
int ans[maxn];
int main()
{
int T,n;
memset(ans,0,sizeof(ans));
for(int m=1;m<maxn;m++)
{
int x=m,y=m;
while(x>0)
{
y+=x%10;
x/=10;
}
if(ans[y]==0 || m<ans[y])
ans[y]=m;
}
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
printf("%d\n",ans[n]);
}
return 0;
}
这里写代码片