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 erro,调不出啊...求助求助啊

Posted by wintersunh at 2008-10-15 02:44:37 on Problem 1002
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include <map>
#include <string>
#include <iostream>
using namespace std;

void tel_Map(char *cp);
void change(char *str);
void taxis(char stp[][99],int *np,int k);

int main(){
	int n,i,j,num[99],k,*np;
	char *sp,exp[99],str[99][99];
	sp=&exp[0];
	np=num;
	cin>>n;
		cin>>exp;
		change(sp);
	    tel_Map(sp);
			strcpy(str[0],sp);
			for(i=0;i<99;i++)
				num[i]=1;
			k=1;
	for(i=1;i<n;i++)
	{   
		cin>>exp;
		change(sp);
	    tel_Map(sp);
            exp[7]='\0';
			for(j=0;j<=k-1;j++)
			{
        if(strcmp(str[j],sp)==0)
		{num[j]++;break;}
  	        }
             if(j>=k)
			 {
			    strcpy(str[k],sp);
				k++;
			 }
	}

taxis(str,np,k);

for(i=0;i<k;i++)
{
   if(num[i]!=1)break;
}
if(i<k)
{for(i=0;i<k;i++)
{if(num[i]!=1)
cout<<str[i][0]<<str[i][1]<<str[i][2]<<"-"<<str[i][3]<<str[i][4]<<str[i][5]<<str[i][6]<<" "<<num[i]<<endl;}}
else cout<<"No duplicates."<<endl; 

		return 0;      
}
void taxis(char stp[][99],int *np,int k){
	    int i,t,temp,n;char set[7];
       n=k;
      for(t=1;t<=n-1;t++)
	  {for(i=0;i<=n-1-t;i++)
      {if(stp[i][0]>stp[i+1][0])
	  {temp=np[i];
       np[i]=np[i+1];
       np[i+1]=temp;
	   strcpy(set,stp[i]);
       strcpy(stp[i],stp[i+1]);
       strcpy(stp[i+1],set);
	  }
       }
	  } 
}

void tel_Map(char *cp){
    	
		map<char,char> letterTable;
      char ch='A';
	 char j='2';
while(j<='9')
{   
if(ch!='Q')	letterTable.insert(map<char,char>::value_type(ch,j));
	            ch++;
				if(ch=='Q') ch++;
if(ch!='Q')	letterTable.insert(map<char,char>::value_type(ch,j));
		        ch++;
if(ch!='Q')	 letterTable.insert(map<char,char>::value_type(ch,j));
			 ch++;
			 
			 j++;}   
	  map<char,char>::iterator iter;

	iter=letterTable.begin();
	while(*cp!='\0')
		{if(*cp>='A'&&*cp<='Y')
		  {iter=letterTable.find(*cp);
		  *cp=iter->second;}
		  
		   cp++;
		}
}

void change(char *str){
    char *next,*record;  
	while(*str!='\0')
	   {if(*str=='-')
	   { next=str;
	    while(*next!='\0')
		{
		   *next=*(next+1);
		   record=next;
			   next++;
		}
             
            *record=*next;
	   }	
	    else
	     str++;
	   }
 }


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