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 boys at 2006-07-18 17:53:56 on Problem 1051
#include <iostream>
#include <cstring>
using namespace std;

struct node 
{
	char ID;
	char *Info;
};
   
int main()
{
	node *N;N=new node[30];
    N[1].ID='A';N[1].Info=".-";N[2].ID='B';N[2].Info="-...";
    N[3].ID='C';N[3].Info="-.-.";N[4].ID='D';N[4].Info="-..";
    N[5].ID='E';N[5].Info=".";N[6].ID='F';N[6].Info="..-.";
	N[7].ID='G';N[7].Info="--.";N[8].ID='H';N[8].Info="....";
	N[9].ID='I';N[9].Info="..";N[10].ID='J';N[10].Info=".---";
	N[11].ID='K';N[11].Info="-.-";N[12].ID='L';N[12].Info=".-..";
	N[13].ID='M';N[13].Info="--";N[14].ID='N';N[14].Info="-.";
    N[15].ID='O';N[15].Info="---";N[16].ID='P';N[16].Info=".--.";
	N[17].ID='Q';N[17].Info="--.-";N[18].ID='R';N[18].Info=".-.";
	N[19].ID='S';N[19].Info="...";N[20].ID='T';N[20].Info="-";
    N[21].ID='U';N[21].Info="..-";N[22].ID='V';N[22].Info="...-";
	N[23].ID='W';N[23].Info=".--";N[24].ID='X';N[24].Info="-..-";
    N[25].ID='Y';N[25].Info="-.--";N[26].ID='Z';N[26].Info="--..";
    N[27].ID='_';N[27].Info="..--";N[28].ID='.';N[28].Info="---.";
    N[29].ID=',';N[29].Info=".-.-";N[30].ID='?';N[30].Info="----";

	int n,i,*a,j,k=0,m;
	cin>>n;	
	char str[1000],*S;
    for(m=1;m<=n;m++)
	{
	    cin>>str;
		S=new char[strlen(str)*4];
		S[0]='\0';
		a=new int [strlen(str)];
		for(i=0;i<strlen(str);i++)
			for(j=1;j<=30;j++)
				if(str[i]==N[j].ID)
				{
			   	a[i]=strlen(N[j].Info);
				 strcat(S,N[j].Info);
				 break;
				}
	  char info1[5];
	  int q=0;
	  cout<<m<<": ";
	  for(i=strlen(str)-1;i>=0;i--)
	  {   
		  for(j=0;j<a[i];j++)
		  {
		  info1[j]=S[q++];
		  }
		  info1[j]='\0';
		  for(k=1;k<=30;k++)  
			if(strcmp(info1,N[k].Info)==0)
			{cout<<N[k].ID;break;}
	  }
	  cout<<endl;
	}
	
	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