我这段代码怎么就只能读入一次字符串啊
  • 板块灌水区
  • 楼主mndogdied
  • 当前回复8
  • 已保存回复8
  • 发布时间2024/8/16 20:42
  • 上次更新2024/8/16 21:18:02
查看原帖
我这段代码怎么就只能读入一次字符串啊
1383979
mndogdied楼主2024/8/16 20:42

我测了,当n==2时,只输入得进一个字符串。

大佬帮忙看看,就是读入的问题。

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define con continue
signed main()
{
	int n;
	cin>>n;
	string s,b="";
	if(n==0)//特判
	{
		cout<<"-1"; 
		return 0;
	}
	unsigned long long a=0ull;
	while(n--)
	{
		getline(cin,s,'\n');
		if(s=="Soul fusion") a+=LLONG_MAX;
		if(s=="GERMANY ORTHOPEDICS") a+=300ull;
		if(s=="Together FOREVER") a+=100ull; 
		if(s=="Kiss") a+=50ull;
		if(s=="Love") a+=20ull;
		if(s=="Like") a+=5ull;
		if(s=="Hug") a+=1ull;
		if(a==ULLONG_MAX)
		{
			if(n==1)
			{
				cout<<"18446744073709551617";
				return 0;
			} 
			if(n==2)
			{
				cout<<"18446744073709551618"; 
				return 0;
			} 
		}
	}
	if(a>=297ull&&a<=299ull) b="\nYeYan:Oh,There are people like me who are hovering on the edge of German orthopedics!";
	cout<<a<<b;
    return 0;
}

2024/8/16 20:42
加载中...