为啥无法输入,直接结束了
查看原帖
为啥无法输入,直接结束了
754146
lucky_loser楼主2022/12/22 15:38

一直没搞懂文件,哪位能给我讲讲?

#include<bits/stdc++.h>
using namespace std;
const int N=100010,key=10000;
int a[N];
int main()
{
	freopen("expr.in","r",stdin);
	freopen("expr.out","w",stdout);
	int x,top=1;
	char ch;
	cin>>a[1];
	while(cin>>ch)
	{
		cin>>x;
		if(ch=='*') a[top]=(a[top]*x)%key;
		if(ch=='+') a[++top]=x;
	}
	int ans=0;
	for(int i=1;i<=top;i++)
		ans=(ans+a[i])%key;
	cout<<ans<<endl;
	return 0;
}
2022/12/22 15:38
加载中...