80分求改

B2068 统计满足条件的 4 位数

wmm13627485615 @ 2024-12-05 15:28:23

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b,c,d,m,cnt=0;
    cin>>n;
    for(int i;i<=n;i++){
        cin>>m;
        d=m%10;
        c=m/10%10;
        b=m/10/10%10;
        a=m/1000;
        if((d-c-b-a)>0) {
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
} 

by Zhengjingwen_mc @ 2024-12-05 15:58:41

@wmm13627485615看第六行,你i没初始化为0,是随机数


by wmm13627485615 @ 2024-12-05 16:42:41

@Zhengjingwen_mc是的是的,感谢感谢大佬!


by Zhengjingwen_mc @ 2024-12-05 16:43:24

@wmm13627485615求关


by wmm13627485615 @ 2024-12-05 21:00:45

@Zhengjingwen_mc一定


|