

- #include
- using namespace std;
- bool cmp(int a,int b){
- return a>b;
- }
- int f(vector<int> &a){
- int k1=0;
- vector<int>b(4,0);
- int k2=0;
- for(int i=0;i<4;i++){
- k1=k1*10+a[i];
- b[3-i]=a[i];
- }
- cout<<" - ";
- for(int i=0;i<4;i++){
- k2=k2*10+b[i];
- cout<
- }
- k1=k1-k2;
- if(k1<1000&&k1>=100){
- cout<<" = 0"<
- }else if(k1<100&k1>=10){
- cout<<" = 00"<
- }else if(k1<10&&k1>0){
- cout<<" = 000"<
- }else cout<<" = "<
-
-
- a[0]=k1/1000;
- a[1]=(k1/100)%10;
- a[2]=(k1/10)%10;
- a[3]=k1%10;
- sort(a.begin(),a.end(),cmp);
- return k1;
- }
- int main(){
- int k1;
- cin>>k1;
- vector<int>a(4,0);
- a[0]=k1/1000;
- a[1]=(k1/100)%10;
- a[2]=(k1/10)%10;
- a[3]=k1%10;
- if(a[0]==a[1]&&a[0]==a[2]&&a[0]==a[3]){
- cout<
" - "<" = "<<"0000"< - return 0;
- }
- sort(a.begin(),a.end(),cmp);
- while(f(a)!=6174){
- }
- return 0;
- }
-
相关阅读:
2022.03青少年软件编程(Python)等级考试试卷(四级)
Java Character.SubSet toString()方法具有什么功能呢?
【极客时间-网络编程实战】
在汽车行业中如何脱颖而出?使用聊天机器人是关键
[Spring] SpringMVC 简介(一)
163_技巧_Power BI 一键批量建立自定义字段参数
使用SecScanC2构建P2P去中心化网络实现反溯源
Linux从入门到精通(十一)——计划任务
神经网络 样本不平衡,神经网络结果不稳定
Ubuntu server 24 (Linux) 安装lua + 卸载软件
-
原文地址:https://blog.csdn.net/aaronyyds/article/details/133965893