【openjudge 计算概论(A)】[指针练习]
#include<cstdio>
using namespace std;
int a[110],n;
int main()
{
int i;
scanf("%d",&n);
for (i=1;i<=n;i++)
scanf("%d",&a[i]);
for (i=n;i>0;i--)
printf("%d ",a[i]);
return 0;
}
#include<cstdio>
#include<cstring>
using namespace std;
int maxn,tm,n,len;
char s[210];
int main()
{
int i,j;
scanf("%d",&n);
for (i=1;i<=n;++i)
{
int t=1;
scanf("%s",s);
len=strlen(s);
for (j=1;j<len;++j)
if (s[j]==s[j-1]) t++;
else
if (t>maxn) maxn=t,tm=s[j-1],t=1;
else t=1;
if (t>maxn) maxn=t,tm=s[len-1];
printf("%c %d\n",tm,maxn);
maxn=tm=0;
}
return 0;
}
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[100010];
int n,len,last;
int main()
{
int i,j,k;
scanf("%d\n",&n);
gets(s);
len=strlen(s);
i=0;j=1;
while(i<len)
{
while(i<len&&j<=80)
++i,++j;
while(s[i]!=' '&&i!=len)
i--,j--;
for (k=last;k<i;++k)
printf("%c",s[k]);
last=i+1;
printf("\n");
j=0;
}
}
#include<cstdio>
#include<cstring>
using namespace std;
int k,n,m;
long long ans;
int main()
{
int i,j,t;
scanf("%d",&k);
for (t=1;t<=k;++t)
{
scanf("%d%d",&m,&n);
for (i=1;i<=m;i++)
for (j=1;j<=n;++j)
{
long long x;
scanf("%lld",&x);
if(i==1||i==m||j==1||j==n) ans+=x;
}
printf("%lld\n",ans);
ans=0;
}
return 0;
}
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[110][110],n,m;
bool p[110][110];
int main()
{
int i,j;
scanf("%d%d",&n,&m);
for(i=1;i<=n;++i)
for(j=1;j<=m;++j)
scanf("%d",&a[i][j]);
for(i=1;i<=n;++i)
for(j=1;j<=m;++j)
if(!p[i][j])
{
int x=i,y=j;
while(x<=n&&y) printf("%d\n",a[x][y]),p[x++][y--]=1;
}
return 0;
}
既然无能更改,又何必枉自寻烦忧