Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

真是奇葩啊,用C能过....

Posted by bhbwudia at 2012-11-12 00:54:44 on Problem 1750
#include <stdio.h>
#include <string.h>
int main()
{
    char s1[50],s2[50];
    int len1,len2;
    int blank=0;
    int i,sum,flag;
    scanf("%s",s1);
    printf("%s\n",s1);
    while(scanf("%s",s2)!=EOF)
    {

        len1=strlen(s1);
        len2=strlen(s2);
        sum=0;
        flag=1;

        for(i=0;i<len1&&i<len2;i++)
        {
            if(s1[i]==s2[i])
            sum++;
            else
            break;
            if(sum>blank)
            {
                 flag=0;
                 blank++;
                 break;
            }
        }
            if(flag)
            blank=sum;
            for(i=0;i<blank;i++)
            printf(" ");
            printf("%s\n",s2);
            strcpy(s1,s2);
        }
        return 0;
    }


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator