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

oms

Posted by 42232619920610 at 2012-06-23 11:30:40 on Problem 2001
#include <stdio.h>
#include <string.h>
int main()
{
char a[1001][21];
int n = 0,i = 0,j = 0,k = 0,mark[1001];
while(gets(a[n]) != NULL && a[n][0])
n ++;
memset(mark,0,sizeof(mark));
for ( i = 0; i< n-1 ;i++ )
{
for ( j = i+1; j < n; j++ )
{
for ( k = 0; a[i][k]!='\0' && a[j][k]!='\0'; k++ )
{
if ( a[i][k] != a[j][k] ) break;
if ( k >= mark[i] ) mark[i] ++;
if ( k >= mark[j] ) mark[j] ++;
}
}
}
for ( i = 0; i < n; i ++)
{
printf( "%s ", a[i]);
for ( k = 0; k <= mark[i]; k ++)
{
char ch = a[i][k];
if(ch!='\0')
putchar(ch);
}
putchar('\n');
}
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