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 doriahe at 2011-05-21 18:09:17 on Problem 1002
#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:
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