C++'s solution to inserting a linear table at the end without outputting spaces:

C++'s solution to inserting a linear table at the end without outputting spaces:

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

Guess you like

Origin blog.csdn.net/weixin_45534301/article/details/109323082