栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 1159 487

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 1159 487

#include <cstdio>#include <cstring>#include <cstdlib>#include <vector>#include <cmath>#include <iostream>#include <algorithm>#include <functional>#include <string>using namespace std;char get(char c){    switch(c)    {    case 'A':    case 'B':    case 'C':        return '2';    case 'D':    case 'E':    case 'F':        return '3';    case 'G':    case 'H':    case 'I':        return '4';    case 'J':    case 'K':    case 'L':        return '5';    case 'M':    case 'N':    case 'O':        return '6';    case 'P':    case 'R':    case 'S':        return '7';    case 'T':    case 'U':    case 'V':        return '8';    case 'W':    case 'X':    case 'Y':        return '9';    }    return ' ';}struct In{    char num[10];}s[100010];int cmp ( const void *a , const void *b ){return strcmp( (*(In *)a).num , (*(In *)b).num );}int main(){    int n,m;    scanf("%d",&n);    while(n--)    {        scanf("%d",&m);        char tmp[100000];        for(int i=0;i<m;i++)        { scanf("%s",tmp); int len=strlen(tmp); int index=0; for(int j=0;j<len;j++) {     if('0'<=tmp[j]&&tmp[j]<='9')     {         s[i].num[index++]=tmp[j];     }     else if('A'<=tmp[j]&&tmp[j]<='Z')     {         s[i].num[index++]=get(tmp[j]);     } }        }        qsort(s,m,sizeof(s[0]),cmp);        bool flag=true;        for(int i=0;i<m;i++)        { int con=1; for(int j=i+1;j<m;j++) {     if(strcmp(s[i].num,s[j].num)==0)     {         con++;         i=j;     }     else     {         break;     } } if(con==1)     continue; printf("%c%c%c-%c%c%c%c %dn",s[i].num[0],s[i].num[1],s[i].num[2],s[i].num[3],s[i].num[4],s[i].num[5],s[i].num[6],con); flag=false;        }        if(flag) printf("No duplicates.n");        if(n!=0) printf("n");    }    return 0 ;}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/373103.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号