IDE里面可以正常输出为什么一个都过不了?
查看原帖
IDE里面可以正常输出为什么一个都过不了?
532121
xb1234楼主2025/7/24 15:41
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	cin.ignore(); // Clear the newline character from the input buffer
	for (int i = 0; i < n; i++) {
		char tempt[1000] = {};
		cin.getline(tempt, 1000);
		int j;
		char s[600] = {};
		for ( j = 0; j < 1000; j++) {
			if (tempt[j] == ' ') {
				tempt[j] = '\0';
				break;
			}
			else {
				s[j] = tempt[j];
			}
		}
		j++;
		int age=0;
		int k;
		for ( k = 0; k < 3; k++) {
			if(tempt[j+k]!=' ')
			age = age * 10 + (tempt[j + k] - '0');
			else {
				break;
			}
			
		}
		k++;
		double score = 0;
		for (int l = 0; l < 3; l++) {
			if (tempt[j + k + l] != '\0')
				score = score * 10 + (tempt[j + k + l] - '0');
			else {
				break;
			}
		}
		age++;
		score = score * 1.2;
		if (score > 600) {
			score = 600;
		}
		cout << s << " " << age << " " << score << endl;
	}
}
2025/7/24 15:41
加载中...