Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
oms#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator