Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
欢迎参加IJCAI 2020麻将智能体竞赛,大奖等你拿!Welcome to IJCAI 2020 Mahjong AI competition with amazing prizes! | 北京大学《ACM/ICPC大学生程序设计竞赛训练》暑期课面向全球招生!

为什么输出格式不对?请教大牛

Posted by pkwang at 2006-09-30 22:27:09 on Problem 2245
#include<iostream> 
#include<string> 
using namespace std; 

int pows(int b,int a)
{
	int www;
	int res = 1;
	if(a == 0)
		return 1;
	for(www = 1;www <= a; www ++)
		res*=10;
	return res;
}
int main() 
{ 
	  
      string str; 
	  char string[100][10];
	  int st[100];
	  int top = -1;
      //cin.get(); 
	  getline(cin,str);
	
	 
	  while(str[0] != '0')
	  {
		  int i;
		  int top=-1,q=-1;
		  int end = str.length();
		  str[end] = '\n';
		  for(i = 2;i < str.length();i++)
		  {
			  q=-1;
			  if(str[i] != ' ')
			  {
				  string[++top][++q] = str[i];
				  while(str[++i] != ' ' && str[i] != '\n')
					  string[top][++q] = str[i];
			  }
			  string[top][++q] = '\0';
		  }
		  int m,n ;
		  n = -1;
		  for(m = 0;m <= top;m ++)
		  {
			  n = -1;
			  while(string[m][++n]);
			  st[m] = 0;
			  int mm;
			  for(mm = 0;mm < n; mm ++)
				  st[m] += (string[m][mm]-48)*pows(10,(n - mm-1));
		  }

		  int a,b,c,d,e,f;
		  for(a = 0;a <= top;a ++)
			  for(b = a + 1;b <= top;b ++)
				  for(c = b + 1;c <= top;c ++)
					  for(d = c + 1;d <= top;d ++)
						  for(e = d + 1;e <= top;e ++)
							  for(f = e + 1;f <= top;f ++)
							  {
								  cout<<st[a]<<' '<<st[b];
								  cout<<' '<<st[c]<<' ';
								  cout<<st[d]<<' '<<st[e]<<' '<<st[f]<<endl;
							  }
		  //cout <<endl;
		   getline(cin,str); 
	  }

      return 0; 
}  

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator