题目链接:http://www.codeforces.com/problemset/problem/271/A
题意:给你一个四位数,求比这个数大的最小的满足四个位的数字不同的四位数。C++代码:#include#include using namespace std;bool chk(int x){ int a[4]; for (int i = 0; i < 4; i ++) { a[i] = x % 10; x /= 10; } sort(a, a + 4); for (int i = 1; i < 4; i ++) if (a[i] == a[i-1]) return false; return true;}int get(const int & x){ for(int i = x+1; ; i ++) if (chk(i)) return i;}int main(){ int n; cin >> n; cout << get(n); return 0;}