传送门:题目
题意:
给一个数字n,找到大于n的一个数字,这个数字不含数字‘0’,问这个数字最小是多少。
题解:
非常水的一道题,比赛的时候先拿的这道题签到,比赛的时候用的取模除法,博客上想用streamstring重新写一下。
AC代码:
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <sstream>
#define debug(x) cout<<#x<<" = "<<x<<endl;
#define INF 0x3f3f3f3f
using namespace std;
int main(void) {
int n;
string str;
cin >> n;
stringstream ss;
for (int i = n + 1;; i++) {
ss.clear();//streamstring多次使用的话,一定要clear一下
ss << i;
ss >> str;
if (str.find('0', 0) == string::npos) {//npos的宏定义是-1
cout << str << endl;
return 0;
}
}
return 0;
}