首页 > 其他 > 详细

NYOJ991 Registration system 【set的用法】

时间:2014-04-08 18:12:00      阅读:457      评论:0      收藏:0      [点我收藏+]

原题链接

#include <set>
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

char buf[100];
char *digitToString(int n){
	sprintf(buf, "%d", n);
	return buf;
}

int main(){
	int n;
	string str, temp;
	set<string> st;
	cin >> n;
	while(n--){
		cin >> str;
		if(st.count(str) == 0){
			st.insert(str);
			cout << "OK" << endl;
		}
		else{			
			for(int i = 1; ; ++i){
				temp = str;
				if(st.count(temp.append(digitToString(i))) == 0){
					st.insert(temp);
					cout << temp << endl;
					break;
				}
			}
		}
	}
	return 0;
}

801811 长木 Registration system bubuko.com,布布扣Accepted 0 308 C/C++ 04-08 09:19:26

NYOJ991 Registration system 【set的用法】,布布扣,bubuko.com

NYOJ991 Registration system 【set的用法】

原文:http://blog.csdn.net/chang_mu/article/details/23162045

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!