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 |
谁来帮帮我吧。。#include"stdio.h" #include "stdlib.h" #include "string.h" #define M 100000 char str[M][8]; void tomap(int i,int j,char ch) { switch (ch) { case '0': case '1': str[i][j] = ch;break; case 'A': case 'B': case 'C': case '2': str[i][j] = '2';break; case 'D': case 'E': case 'F': case '3': str[i][j] = '3';break; case 'G': case 'H': case 'I': case '4': str[i][j] = '4';break; case 'J': case 'K': case 'L': case '5': str[i][j] = '5';break; case 'M': case 'N': case 'O': case '6': str[i][j] = '6';break; case 'P': case 'R': case 'S': case '7': str[i][j] = '7';break; case 'T': case 'U': case 'V': case '8': str[i][j] = '8';break; case 'W': case 'X': case 'Y': case '9': str[i][j] = '9';break; } } int cmp(const void* pch1,const void* pch2) { return strcmp((char*)pch1,(char*)pch2); } int main() { unsigned int i,j,k,x,n; char strtemp[16] = {0}; int count; while (scanf("%d",&n)!=EOF) { count = 1; for (k=0; k<n; k++) { //i = k; x = 0; scanf("%s",strtemp); //str[i] = strtemp; for(j = 0;j <= strlen(strtemp);j++) { if(j==3) { str[k][x] = '-'; x++; } if(strtemp[j] != '-') { tomap(k,x,strtemp[j]); x++; } } //str[k][x] = 0; printf("%s\n",str[k]);//输出1 } //qsort(str,n,9,cmp); for( i = 0; i < n; i++ ) { puts(str[i]);//为什么和输出1这里的不一样??? if(strcmp(str[i],str[i+1]) == 0) count++; else if(count >= 2) { printf("%s %d\n",str[i],count); count = 1; } } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator