首页 > 其他 > 详细

uva 644 - Immediate Decodability

时间:2015-07-16 21:34:18      阅读:194      评论:0      收藏:0      [点我收藏+]
#include<iostream>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;

char codes[9][12];
int k = 1,num;

bool solve(){
    for(int i = 0; i < num; i++){
        for(int j = 0; j < num; j++){
            int flag = 1;
            if(j!=i && strlen(codes[j]) > strlen(codes[i])){
                for(int k = 0; k < strlen(codes[i]); k++)
                    if(codes[i][k] != codes[j][k])
                        flag = 0;
                if(flag)
                    return false;
            }
        }
    }
    return true;
}

int main(){
    num = 0;

    while(cin >> codes[num]){
        if(codes[num][0] == ‘9‘){
            if(solve())
                cout << "Set " << k++ << " is immediately decodable" << endl;
            else
                cout << "Set " << k++ << " is not immediately decodable" << endl;
            num = 0;
        }else
            num++;
    }

    return 0;
}

 

uva 644 - Immediate Decodability

原文:http://www.cnblogs.com/yong-hua/p/4652330.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!