C++对于插入线性表末尾不输出空格的解决方法:

C++对于插入线性表末尾不输出空格的解决方法:

for(i=0;i<n;i++){
    
    
		//此处末尾会多输出一个空格
		//cout<<s.elem[i]<<" ";
		//解决:第一个数不加空格,后面的数在前面加空格
		if(i==0)
			cout<<s.elem[i];
		else{
    
    
			cout<<" "<<s.elem[i];
		}
		
			 
	}

猜你喜欢

转载自blog.csdn.net/weixin_45534301/article/details/109323082
今日推荐