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

一开始没懂题意 后来看了下别人的 懂了 然后一次AC 附代码

Posted by Ink213 at 2012-12-16 14:26:52 on Problem 1750
#include<stdio.h>
#include<string.h>
int len(char a[],char b[]){
    int s1,s2,i,length;
    s1=strlen(a),s2=strlen(b);
    length=0;
    for(i=0;i<s1&&i<s2;i++)
        if(a[i]==b[i]) length++;
        else break;
    return length;
}
int main(){
    char s[100005][12];
    int i,j,k,flag,space,t;
    for(i=1;gets(s[i]);i++)
	    if(strlen(s[i])==0) break;
    flag=0,space=1;
    for(j=1;j<i;j++){
	    if(flag==0) {printf("%s\n",s[j]);flag=1;}
            else {
	       if(s[j][0]==s[j-1][0]){
                  space=space<len(s[j],s[j-1])?space:len(s[j],s[j-1]);
		  for(k=1;k<=space;k++)
                       printf(" ");
                  printf("%s\n",s[j]);
		  space++;
	       }
	       else {
		   space=1;
	           printf("%s\n",s[j]);
	       }
	    }
    }
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