是不能用cin吗?为什么会0分啊
查看原帖
是不能用cin吗?为什么会0分啊
555584
weiming3楼主2023/2/25 23:18
#include <iostream>
#include<algorithm>
#include <math.h>
using namespace std;
int main() {
	char a[4001];
	int t = 0;
	while (cin >> a[t]) {
		t++;
	}
	if(a[t-1]=='\n'){
		t--;}
		
	cout << sqrt(t) << " ";
	int m = a[0] - '0';
	int tmp = 0;
	for (int i = 0; i <= t - 1; i++) {
		if (a[i] - '0' == m) {
			tmp += 1;
		} else {
			cout << tmp << " ";
			tmp = 1;
			m ^= 1;
		}
	}
	return 0;
}

本地的测试样例没有问题啊,为什么到Oj上会0分

2023/2/25 23:18
加载中...