No foothold 1

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.