No foothold 1
Description
Zoxiao has been playing the game for no reason recently. He has a good rating on this game. It combines FPS and RPG elements to ensure high playability. However, he discovered that the generation of task systems were not doing well, and the task system did not help him determine the number of tasks in which region, and the tasks were scattered. For example, in area 1, you receive four tasks. In area 2, you receive three tasks. After a game lasts for a while, you have received 3 tasks in another task point in area 1 (the previous task was not completed), and 9 tasks in Area 3 ...... He feels messy. Now he wants to design a program to count the number of tasks in each region.
-
Input
-
Multiple groups of test data, with 0 input to end each group of data occupies a row, input m region, N tasks (0 <m, n <100)
-
Output
-
Output the statistical results of each region (sorting is not required)
-
Sample Input
-
1 32 33 41 70 0
-
Sample output
-
1 102 33 4
#include <iostream>using namespace std;int main(){ int m,n; int mm[10000]; int k=0; int a[10000]; for(int i=0;i<10000;i++) mm[i]=0; while(cin>>m>>n && !(m==0 && n==0)) { mm[m]+=n; a[k++]=m; } for(int i=0;i<k;i++){ for(int j=i+1;j<k;j++){ if(a[i]==a[j]) { for(int g=j;g<k-1;g++) { a[g]=a[g+1]; } k--; } } } for(int i=0;i<k;i++) { cout<<a[i]<<" "<<mm[a[i]]<<endl; } return 0;}
No foothold 1