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

指针有什么错误呀???

Posted by sleepboy at 2004-10-02 12:32:07 on Problem 1654
#include<iostream.h>
void main()
{
	char *str,*p;
	int n;
	int x,y,xx,yy;
    int ok;
	float area;
	int area1;
	cin>>n;
	while(n>=1){
		cin>>str;
		p=str;
		ok=0; area=0;area1=0; x=0;y=0;xx=0;yy=0;
        while(!ok){
		switch(*(p++)){
			case '1' :
				xx=x-1;yy=y-1;break;
			case '2' :
				yy=y-1;	  break;
			case '3':
				xx=x+1;yy=y-1;break;
			case '4':
				xx=x-1;break;
			case '5':
				ok=1; break;
			case '6':
				xx=x+1;break;
			case '7':
				xx=x-1;yy=y+1;break;
			case '8':
				yy=y+1;   break;
			case '9':
				xx=x+1;yy=y+1;

		}
		area1 += (yy+y)*(xx-x);
		x=xx;y=yy;
		}
		area = float(area1) / 2.0;
		area = area > 0 ? area : -area;
        cout<< area << endl ;
		n--;
	}
}                    
我用turbo c++3.0编译和运行都没有错误,但是用turbo c++3.0编译能通过但运行时却报错: 3 cause a General Protection Fault in module KRNL386 at 0002:2fd4 

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