求调,怎么错的呢?
查看原帖
求调,怎么错的呢?
1255744
crolinde楼主2025/2/8 14:29
#include <bits/stdc++.h>
using namespace std;
int n, a;
int cnt, ans;

int main() {
	cin >> n;
	while (n--) {
		cin >> a;
		for (int i = 0; i < a; i++) {
			cnt += a % 10;
			a /= 10;
		}
		if (cnt % 7 == 0) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
    //没有下面的判断最后一个数字会判断错误
		if (n == 1) {
			cnt = 1;
		} else {
			cnt = 0;
		}
	}
	return 0;
}

2025/2/8 14:29
加载中...