关于神奇读入
查看原帖
关于神奇读入
250699
mot1ve楼主2020/9/7 10:19

这样为什么读的时候while cin会一直运行到全读完? 不应该以换行符为界限吗

#include<bits/stdc++.h>
using namespace std;
int a[1010][1010];//邻接矩阵建图,存每条边的颜色
int m,n,u,v,col;
int main()
{
	cin>>m>>n;
	for(int i=1;i<=m;i++)
	{
		u=0,col++;
		while(cin>>v)
		{
			if(u!=0)
			a[u][v]=col;
			u=v;
		}
	}
	cout<<a[5][3];
	return 0;
} 
2020/9/7 10:19
加载中...