30分,过样例,求调
  • 板块P1953 易语言
  • 楼主dream_qwq
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/4/24 13:11
  • 上次更新2024/4/24 18:20:33
查看原帖
30分,过样例,求调
739784
dream_qwq楼主2024/4/24 13:11

测试点错误如下,求调,谢谢!

#include <bits/stdc++.h>
using namespace std;
string suffix_in, suffix_out,str;
string name;
int number_name;
string obtain(string s)
{
    suffix_in = suffix_out = "";
    string str="";
    int Points=0;
    for (int i = 0;i<s.size();i++){
        if(s[i]>='0'&&s[i]<='9'){
            number_name *= 10;
            number_name += s[i] - '0';
            Points = 1;
        }
        else if(Points==1){
            if(s[i]!='.'&&s[i]!=' ') suffix_in += s[i];
            if(s[i]==' ')
                Points = 2;
        }
        if(Points==2&&s[i]!=' ')
            suffix_out += s[i];
        if(Points==0)
            str += s[i];
    }
    return str;
}
string obtain2(string s){
	int Points=0;
	string str="";
	for(int i=0;i<s.size();i++){
		if(s[i]=='.') Points++;
		if(s[i]==' ') Points++;
		if(Points==0) str+=s[i];
		if(Points==1&&s[i]>='a'&&s[i]<='z') suffix_in+=s[i];
		if(Points==3&&s[i]>='a'&&s[i]<='z') suffix_out+=s[i];
	}
	return str;
}
int main()
{
    getline(cin,str);
    if(str!="1"&&str!="0"){
        name = obtain(str);
        int rows=1;
        string temp;
        getline(cin, temp);
        for (;!temp.empty();rows++)
            getline(cin, temp);
        for (int i = number_name; i < rows+number_name-1;i++){
            cout << name << i << "." << suffix_in << " ";
            cout << name << i << "." << suffix_out << "\n";
        }
    }else{
    	string s;
        getline(cin, s);
        int rows=1;
        string temp="114514";
        for (;!temp.empty();rows++)
            getline(cin, temp);
        name = obtain2(s);
        if(str=="1")
	        for (int i = 1; i < rows;i++){
	            cout << name << "." << suffix_in << i << " ";
	            cout << name << "." << suffix_out << i << "\n";
	        }
	    else
	        for (int i = 0; i < rows-1;i++){
	            cout << name << "." << suffix_in << i << " ";
	            cout << name << "." << suffix_out << i << "\n";
	        }
	}
    return 0;
}

/*
enger10.in ans
abc1.in abc1.out
abc2.in abc2.out
abc3.in abc3.out
abc4.in abc4.out

*/
  
2024/4/24 13:11
加载中...