-
Notifications
You must be signed in to change notification settings - Fork 0
/
10814_bueno.cpp
68 lines (53 loc) · 999 Bytes
/
10814_bueno.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <bits/stdc++.h>
using namespace std;
typedef struct node *pnode;
typedef struct node
{
char name[102];
pnode link;
};
pnode a[201] = {NULL};
int main() {
int n;
pnode temp, pretemp;
scanf("%d", &n);
for(int i = 0; i<n ; i++)
{
int age; char tname[102];
scanf("%d %s", &age, &tname);
if(a[age] == NULL){
a[age] = (pnode)malloc(sizeof(node));
strcpy(a[age]->name, tname);
a[age]->link = NULL;
}
else
{
temp = a[age];
while(temp)
{
pretemp = temp;
temp = temp->link;
}
if(temp == NULL){
pretemp->link = (pnode)malloc(sizeof(node));
pretemp = pretemp->link;
strcpy(pretemp->name, tname);
pretemp->link = NULL;
}
}
memset(tname, 0, 101);
}
for(int i = 1; i<201; i++)
{
if(a[i] != NULL)
{
temp = a[i];
while(temp)
{
printf("%d %s\n", i, temp->name);
temp = temp->link;
}
}
}
return 0;
}