为什么测试数据没问题,提交后全wa
查看原帖
为什么测试数据没问题,提交后全wa
443134
adtom楼主2023/3/1 18:55
//#include<iostream>
//#include<cmath>
#include<stdio.h>
//#include<string.h>
using namespace std;
int main(){
	int temp=0,j=0,flag=1,a[300]={0};
	char c[1000]={};
	fgets(c,1000,stdin);  
	for(int i=0;i<strlen(c)-1;i++){
		if(c[i]!=32){
			flag=1;
			temp++;
		}else{
			if(flag==1){
				a[j++]=temp;
				flag=0;
				temp=0;
			}
			continue;
		}
		if(i==strlen(c)-2)
			a[j++]=temp;
	}
	for(int i=0;i<j;i++){
		if(i<j-1)
			cout<<a[i]<<',';
		else 
			cout<<a[i];
	}
}
 
2023/3/1 18:55
加载中...