51分,哪位大佬帮忙看看,谢谢!
查看原帖
51分,哪位大佬帮忙看看,谢谢!
559725
Vickywei楼主2022/8/6 19:36
#include <bits/stdc++.h>
using namespace std;
char t[110];
string a[20],w="";
int k=0;
int ans[20];
int get(string tt){
	int res=0;
	if (tt.find("/")!=-1) return 10;
	res+=tt[0]-'0';
	if (tt.size()==2) res+=tt[1]-'0';
	return res;
}
int main(){
	cin.getline(t,100);
	for (int i=0;i<strlen(t);i++){
		if (t[i]!=' '){
			w=w+t[i];
			if (i==strlen(t)-1||t[i+1]==' '){
				a[++k]=w;
				w="";
			}
		}
	}
    k=0;
	for (int i=1;i<=10;i++){
	    int score=0;
		if (a[i]=="/"){
			score+=10;
			score+=get(a[i+1]);
			if (a[i+1].size()==1){
				string tt=" ";
				tt[0]=a[i+2][0];
				score+=get(tt);
			}
		}
		else if (a[i].find("/")!=-1){
			score+=10;
			string tt=" ";
			tt[0]=a[i+1][0];
			score+=get(tt);
		}
		else score+=get(a[i]);
		ans[k+1]=ans[k]+score;
		k++;
		printf("%d ",score);
	}
	printf("\n");
	for (int i=1;i<=k;i++){
		printf("%d ",ans[i]);
	}
	return 0; 
}
2022/8/6 19:36
加载中...