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 |
坑爹的cin·····终于过了,贴上来纪念……^_^#include <iostream> #include <stdio.h> #include <cstring> #include <algorithm> using namespace std; int map[] = {2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9}; int compare (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int main() { int n , x, N; char temp[50]; cin >> N; n = N; int *count = new int [N]; int *a = new int [N]; memset(a,0,sizeof a * N); memset(count,0,sizeof count * N); while(n--) { // cin >> temp; scanf("%s",temp);//尼玛啊,scanf一次过,他瞄的cin死活过不鸟,cin你个垃圾!!!!!! x = 0; int length = strlen(temp); for (int i = 0; i < length; i++) { if(temp[i] == '-') continue; if(temp[i] >= '0' && temp[i] <= '9') x += (int)temp[i] - 0x30; else x += map[temp[i] - 'A']; x *= 10; } x /= 10; a[n] = x; } // cout << endl; // for (int i = 0; i < N; i++) // cout << a[i] << ' '; // cout << endl; qsort(a , N ,sizeof(int),compare); // for (int i = 0; i < N; i++) // cout << a[i] << ' '; // cout << endl; for (int i = 1; i < N; i++) { if(a[i] == a[i-1]) { count[i] = count[i-1] + 1; count[i-1] = 0; } } bool flag = false; for (int i = 0; i < N; i++) { if(count[i] != 0) { flag = true; break; } } if(flag == false) { cout << "No duplicates." << endl; return 0; } for (int i = 0; i < N; i++) { if(count[i] == 0) continue; // p = 1000000; // for (int j = 0; j < 7; j++) // { // cout << a[i] / p % 10; // p /= 10; // if(j == 2) // cout << '-'; // } printf("%03d-%04d %d\n",a[i]/10000,a[i]%10000,count[i] + 1);//有printf,cout你就滚吧!! } // for (int i = 0; i < N; i++) // cout << a[i] << ' '; // cout << endl; return 0 ; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator