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

runtime error!哪位牛人帮帮我!

Posted by xuzhiquan at 2010-04-22 21:38:00 on Problem 1176
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int Nlamp=0;
int Npress=0;
int on[101]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int off[101]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
char str[8][101]={
"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",//1或者2
"0011100011100011100011100011100011100011100011100011100011101001110001110001110001110001110001110011",//
"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101",//1或3
"0110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110110",//4
"1001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001",//3,2
"1010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010",//1,3
"1100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100011100",//
"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"//0,3
};
int oo[8]={0,1,0,2,1,0,1,1}; //字符串次数的要求
int main()
{
	scanf("%d",&Nlamp);
	scanf("%d",&Npress);
	vector<int> a;
	vector<int> b;
	vector<int> c;
	int change1=0;
	int change2=0;
	int i=0,j=0,j2=0,k=0;
	for(i=0;;i++)
	{
	cin>>j;
    if(j!=-1)
	{on[j-1]=1;
	a.push_back(j);
	change1=1;
	}   
	if(j==-1)
	{
	break;}
	
	}
	for(i=0;;i++)
	{
	cin>>j2;
	if(j2!=-1)
	{off[j2-1]=0;
	b.push_back(j2);
	change2=1;
	}
	if(j2==-1)
	{	
		break;}
	}
	for(i=0;i<8;i++)
	{
		c.push_back(i);
	}
	
	for(k=0;k<8;k++)
	for(i=0;i<a.size();i++)
	{	if(str[k][a[i]-1]-'0'!=on[a[i]-1]&&change1==1)
			c.erase(std::find(c.begin(),c.end(),k));
	}
	for(k=0;k<8;k++)
	for(i=0;i<b.size();i++)
	{	
		if(str[k][b[i]-1]-'0'!=off[b[i]-1]&&change2==1)
			c.erase(std::find(c.begin(),c.end(),k));
	}
	i=0;
	k=0;
     for(i=0;i<c.size();i++)
	 {  if(Npress>oo[c[i]]||Npress==1&&c[i]==3)
	 {
		 for(k=0;k<Nlamp;k++)
		 {cout<<str[c[i]][k];
		 }
	 cout<<endl;
	 }
	 }
	 a.clear();
	 b.clear();
	 c.clear();
	//	system("pause");
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