字符串

hdu1073
#include<stdio.h>
#include<string.h>
char a1[5050],b1[5050];
char a2[5050],b2[5050];
void fun(char a[],char b[])
{
    char tmp[5050];
    gets(tmp);
    while(strcmp(tmp,"START")!=0) gets(tmp);
    while(gets(tmp))
    {
        if(strcmp(tmp,"END")==0) break;
        if(strlen(tmp)>0) strcat(a,tmp);
        strcat(a,"\n");
    }
    int t=0,len=strlen(a);
    for(int i=0;i<len;i++)
    {
        if(a[i]!=' '&&a[i]!='\t'&&a[i]!='\n')
          b[t++]=a[i];
    }
    b[t]='\0';
}
int main()
{
    //freopen("Input.txt","r",stdin);
    int ncase;
    scanf("%d",&ncase);
    while(ncase--)
    {
        a1[0]='\0';
        a2[0]='\0';
        fun(a1,b1);
        fun(a2,b2);
        if(strcmp(a1,a2)==0) printf("Accepted\n");
        else if(strcmp(b1,b2)==0) printf("Presentation Error\n");
        else printf("Wrong Answer\n");
    }
    return 0;
}

hdu1200
#include<stdio.h>
#include<string.h>
char map[22][22];
char a[500];
int main()
{
    //freopen("Input.txt","r",stdin);
    int n,i,j,k;
    while(scanf("%d",&n)&&n)
    {
        getchar();
        gets(a);
        k=strlen(a);
        int x=0,y=0,flag=0;
        for(i=0;i<k;i++)
        {
            map[x][y]=a[i];
            if(y==n-1&&flag==0){map[x][++y]='\0';flag=1;x++;map[x][y]='\0';}
            if(flag==0) y++;
            if(flag==1) y--;
            if(y==-1) { flag=0;x++;y++;}
        }
        /*for(i=0;i<x;i++)
        {
            for(j=0;j<n;j++)
              printf("%c",map[i][j]);
            puts("");
        }*/
        memset(a,0,sizeof(a));
        n=0;
        for(i=0;i<k;i++)
         for(j=0;j<x;j++)
          a[n++]=map[j][i];
        a[n]='\0';
        puts(a);
    }
    return 0;
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值