求问
  • 板块学术版
  • 楼主__Function__
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/10/13 19:26
  • 上次更新2024/10/13 21:45:15
查看原帖
求问
1324175
__Function__楼主2024/10/13 19:26

下面给大家两段代码

1st

#include <bits/stdc++.h>
#define int long long
using namespace std;
int s(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
signed main()
{
	int n;
	int x;
	cin >> n;
	while (n --) {
		cin >> x;
		int t = s(x);
		if(t % 7 == 0)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
    return 0;
}

2nd

#include <bits/stdc++.h>
#define int long long
using namespace std;
int s(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int n;
	int x;
	cin >> n;
	while (n --) {
		cin >> x;
		int t = s(x);
		if(t % 7 == 0)
			cout << "Yes\n";
		else
			cout << "No\n";
	}
    return 0;
}

可见,上面两段代码除了io方式,其他都一样,但是(样例这里取)输出却不一样,这是为什么?

2024/10/13 19:26
加载中...