| ||||||||||
| 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 | |||||||||
输出No duplicates.的时候,用cout可以,用printf就报错为什么呢?#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int convert(char ch)
{
if(ch=='A' || ch=='B' || ch=='C')
return 2;
if(ch=='D' || ch=='E' || ch=='F')
return 3;
if(ch=='G' || ch=='H' || ch=='I')
return 4;
if(ch=='J' || ch=='K' || ch=='L')
return 5;
if(ch=='M' || ch=='N' || ch=='O')
return 6;
if(ch=='P' || ch=='R' || ch=='S')
return 7;
if(ch=='T' || ch=='U' || ch=='V')
return 8;
if(ch=='W' || ch=='X' || ch=='Y')
return 9;
}
int time[10000000];
bool is[10000000];
int num[100000];
int main()
{
int n;
while(cin>>n)
{
memset(time,0,sizeof(time));
memset(is,false,sizeof(is));
int ps=0;
bool flag=false;
for(int i=0;i<n;i++)
{
int x=0;
char s[20];
cin>>s;
for(int j=0;s[j]!='\0';j++)
{
if(s[j]=='-' || s[j]=='Q' || s[j]=='Z')
continue;
else if(s[j]<='9')
x=x*10+s[j]-'0';
else if(s[j]<='Z')
x=x*10+convert(s[j]);
}
time[x]++;
if(!is[x] && time[x]>=2)
{
flag=true;
is[x]=true;
num[ps++]=x;
}
}
if(!flag)
// cout<<"No duplicates."<<endl;
printf("No duplicates.\n");
else
{
sort(num,num+ps);
for(int i=0;i<ps;i++)
printf("%03d-%04d %d\n",num[i]/10000,num[i]%10000,time[num[i]]);
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator