20分求助
查看原帖
20分求助
1323415
wky_wsy_楼主2024/7/15 12:35

不知道为啥好像有几个测试点输出不出来

#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,s,g,z[3]={0},l=0,l1=0,c=0;
    scanf("%d",&a);
    
    while(b!=4&&s!=9&&g!=5){
        b=a/100;
        s=a%100/10;
        g=a%10;
        if(g>s){
            z[0]=max(b,g);
            z[1]=min(b,g);
            z[2]=s;
        }
        else{
            z[0]=max(b,s);
            z[1]=min(b,s);
            z[2]=g;
        }
        l=z[0]*100+z[1]*10+z[2];
        l1=z[2]*100+z[1]*10+z[0];
        a=l-l1;
        c++;
        if(a==495){
            printf("%d",c);
            break;
        }
    }
    return 0;
}
2024/7/15 12:35
加载中...