关于本题读入
查看原帖
关于本题读入
250699
mot1ve楼主2022/11/19 09:33

为什么这样读入最后会少一行?

#include<bits/stdc++.h>
using namespace std;
int w,h;
char c[110][110];
int main()
{
	cin>>w>>h;
	for(int i=1;i<=h*2+1;i++)
	{
		string s;
		getline(cin,s);
		for(int j=0;j<s.size();j++)
		{
			c[i][j+1]=s[j];
		}
	}
	for(int i=1;i<=h*2+1;i++)
	{
		for(int j=1;j<=w*2+1;j++)
		{
			cout<<c[i][j];
		}
		cout<<endl;
	}
	return 0;
}
2022/11/19 09:33
加载中...