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

代码!

Posted by chenxuan123456789 at 2012-07-31 20:20:32 on Problem 3630
#include<iostream>
using namespace std;
 
int cases, count;
char tel[10005][11];
int i, j;
 
int cmp(const void *a, const void *b)
{
    return strcmp( (char*)a,(char*)b );
}
 
int main()
{
    scanf("%d",&cases);
    while(cases--)
    {
        bool flag = true;
        scanf("%d",&count);
        for(i = 0; i < count; i++)
            scanf("%s",tel[i]);
        qsort(tel,count,sizeof(char)*11,cmp);
        int len1, len2;
        for(i = 1; i < count; i++)
        {
            len1 = strlen(tel[i-1]);
            len2 = strlen(tel[i]);
            j = 0;
            if(len1 <= len2)
            {
                while(tel[i-1][j] == tel[i][j] && j < len1)
                    j++;
                if(j == len1)
                    flag = false;
            }
            if(!flag)
                break;
        }
        if(flag)
            printf("YES\n");
        else
            printf("NO\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