unowned Land 1 time limit: 1000 ms | Memory limit: 65535 KB Difficulty: 0 Description of the son Xiao recently in the play without the ground 1, he is a good evaluation of the game, combining FPS and RPG elements, can play a high degree. However, he found a generation of task system does not do well, the task system does not help him to figure out which area has how many tasks, and, to the task, but also more scattered. For example, at a task point in area 1, you have 4 tasks, 2 area of a task, you received 3 tasks; After a period of time, you are in the 1 area another task to get 3 tasks (before the task has not completed), 3 areas have been 9 tasks ... He feels messy, and now he's going to design a program to count how many tasks each area has. Enter multiple sets of test data to enter 0 0 end
One row for each set of data, input m region, n task (0<m,n<100) Output output statistics results for each region (do not require sorting) sample input
1 3
2 3
3 4
1 7
0 0
Sample output
1
2 3
3 4
#include <stdio.h>
int main ()
{
int a[100] = {0}, M, n, r = 1, I;
while (1)
{
scanf ("%d%d", &m, &n);
if (m = = 0 && n = = 0)//when m==0 and n==0 jump out
Break
if (r <= m)//Find out the number of loops
r = m;
A[M] = a[m] + N;
}
for (i = 1; I <= R; i++)//sequentially output.
{
printf ("%d", I);
printf ("%d\n", A[i]);
}
return 0;
}
Their first code, no errors, but ignored a word is unable to sort.
#include <stdio.h>
int main ()
{
int a[100] = {0}, m, N, I, r = 1, b[100] ={0}, q;
while (1)
{
scanf ("%d%d", &m, &n);
if (m = = 0 && n = 0)
Break
for (i = 1; i < 1000; i++)
{
if (B[i]!= m && b[i] = = 0)//if b[i]!= m and b[i] = 0 let b[i] = = M. If the b[i]==m is added, if b[i] = = 0, the area is just beginning to count.
B[i] = m;
if (b[i] = = m)
Break
}
if (R <= m)
r = m;
A[M] = a[m] + N;
}
for (i = 1; I <= R i++)
if (B[i]!= 0 && A[b[i]]!= 0)//The output of the answer is not 0 0, so to exclude
printf ("%d%d\n", B[i], a[b[i]);
return 0;
}
Spent several days, just at the beginning do not know what wrong, after has been in the wrong sort.
Online prompts to warn posterity for example input 1 3 4 2 1 7 2 1 00 output should be 1 10 4 2 2-1