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

1A

Posted by makuiyu at 2013-11-29 19:31:19 on Problem 3852
#include <iostream>
#include <cstdio>

#define N 110

using namespace std;

char s[N][N];

int main()
{
    int n;
    char *c1, *c2;
    bool judge;
    int i, j, k;
    while(scanf("%d", &n)!=EOF && n!=0)
    {
        for(i=0; i<n; ++i)
            scanf("%s", s[i]);
        judge = true;
        for(k=0; judge; ++k)
            for(i=0; i<n; ++i)
            {
                if(s[i][k]=='\0' || !judge)
                {
                    judge = false;
                    break;
                }
                for(j=i+1; j<n; ++j)
                {
                    c1 = &s[i][k];
                    c2 = &s[j][k];
                    if(strcmp(c1, c2) == 0)
                    {
                        judge = false;
                        break;
                    }
                }
            }
        printf("%d\n", k-2);
    }
    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