yahu2023 @ 2023-10-05 16:07:11
#include <iostream>
using namespace std;
int main()
{
int ge,shi,bai,qian,n,i;
cin >> i;
int arr[i];
for(int ini = 0;ini <= i - 1;ini++)
{
cin >> arr[ini];
}
for(int ini = 0;ini <= i - 1;ini++)
{
ge = 0;
shi = 0;
bai = 0;
qian = 0;
ge = arr[ini] % 10;
shi = arr[ini] % 100 - ge;
bai = arr[ini] % 1000 - ge - shi * 10;
qian = (arr[ini] - ge - shi * 10 - bai * 100)/1000;
if(qian - bai - shi - ge > 0)
{
n++;
}
}
cout << n;
return 0;
}
by AquaDaMean1e @ 2023-10-06 08:44:42
有一些问题你看一下
#include <iostream>
using namespace std;
int main()
{
int ge,shi,bai,qian,n=0,i;//n最好给个初值
cin >> i;
int arr[i+10];//数组多开10个
for(int ini = 0;ini <= i - 1;ini++)
{
cin >> arr[ini];
}
for(int ini = 0;ini <= i - 1;ini++)
{
ge = 0;
shi = 0;
bai = 0;
qian = 0;
ge = arr[ini] % 10;
shi = (arr[ini] / 10) % 10;
bai = (arr[ini] / 100) % 10;
qian = (arr[ini] / 1000) % 10;//你分离位数的方法错了
if(ge - bai - shi - qian > 0)//注意审题 是拿个位减
{
n++;
}
}
cout << n;
return 0;
}