271A题目网址
题目解析
1.输入一个年份,求这个年份之后的每一个数字都各不相同的年份
举例:
输入:
2013
输出:
2014
2.求年份(四位数)的每一位数,再把这些数逐个比较
四位数求:
千位:n/1000
百位:n%1000/100
十位:n%100/10
个位:n%10/1;
代码
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main()
{ int year=0,result=0;int a=0,b=0,c=0,d=0;scanf("%d",&year);for(int i=1;i<=9000;i++){result=year+i;a=result/1000;//千位b=result%1000/100;//百位c=result%100/10;//十位d=result%10/1;//个位if(a!=b&&a!=c&&a!=d&&b!=c&&b!=d&&c!=d){printf("%d",result);break;}}getchar();system("pause");return 0;
}