CodeForces 4C

MAP容器简单题

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <map>
 4 #include <string.h>
 5 #include <cstring>
 6 #include <string>
 7 using namespace std;
 8 map<string,int> b;
 9 int main(){
10     int n;
11     char s[35];
12     scanf("%d",&n);
13     getchar();
14     for(int i=0;i<n;i++){
15         scanf("%s",s);
16         if(b[s]!=0){
17             int k=b[s];
18             printf("%s%d
",s,k);
19             b[s]++;
20         }
21         else {
22             printf("OK
");
23             b[s]++;
24         }
25     }
26     return 0;
27 }
原文地址:https://www.cnblogs.com/Mr-Xu-JH/p/3887126.html