| ||||||||||
| 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 <iostream>
#include <string>
using namespace std;
#define max 1000
string get_number(void);
string change_str(string str);
char get_num(char num);
void cout_number(string *number,string num,int *count,int &p);
int main()
{
string cout_num[max];
int cout_nun[max],i,mark,p=0,flag = 0;
cin >> mark;
for(i = 0;i < mark;i++)
cout_number(cout_num,get_number(),cout_nun,p);
for( i = 0;i < p;i++)
if( cout_nun[i] > 1)
{
cout << cout_num[i] << " " << cout_nun[i] <<endl;
flag = 1;
}
if(flag == 0)
cout << "No duplicates."<<endl;
return 0;
}
string get_number(void)
{
string temp;
cin >> temp;
return change_str(temp);
}
string change_str(string str)
{
string temp;
int i,j=0;
for(i = 0;i < str.length(); i++)
{
if((isdigit(str[i]) || isalpha(str[i])) && toupper(str[i]) != 81&& toupper(str[i]) != 90)
{
if(j == 3)
temp += '-';
if(isdigit(str[i]))
temp += str[i];
if(isalpha(str[i]))
temp += get_num(toupper(str[i]));
j++;
if(temp.length() == 8)
return temp;
}
}
return temp;
}
char get_num(char num)
{
if(num < 68)
return '2';
if(num < 71)
return '3';
if(num < 74)
return '4';
if(num < 77)
return '5';
if(num < 80)
return '6';
if(num < 84 &&num!=81)
return '7';
if(num < 87)
return '8';
if(num < 90)
return '9';
else
return NULL;
}
void cout_number(string *number,string num,int *count,int &p)
{
int i,k = 1,j;
for(i = 0; i < p;i++)
{
if(number[i] == num)
{ count[i]++;
k = 0;
}
}
if(k == 1)
{
i = 0;
while( i < p && num > number[i])
i++;
if(i==p)
{
number[p] = num;
count[p] = 1;
}
else
{
for(j = p;j>i;j--)
{
number[j] = number[j-1];
count[j] = count[j-1];
}
number[i] = num;
count[i] = 1;
}
++p;
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator