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

Re:郁闷,为什么我自己运行可以,提交总是不过!

Posted by 19920118 at 2011-07-05 10:35:49 on Problem 3979
In Reply To:郁闷,为什么我自己运行可以,提交总是不过! Posted by:fanglongfei at 2011-03-25 22:52:36
> #include<stdio.h>
> #include<math.h>
> 
> int gcd(int x,int y)
> {
> 	int t=0;
> 	while(x%y!=0)
> 	{
> 		t=x%y;
> 		x=y;
> 		y=t;
> 	}
> 	if(y<0)
> 		y=-1*y;
> 	return(y);
> }
> int main()
> {
> 	int a,b,c,d,m,n,i=0,tmp;
> 	char date[7];
> 	while((date[0]=getchar())!=EOF)
> 	{
> 	
> 		for(i=1;i<7;i++)
> 			date[i]=getchar();
> 		getchar();
> 		a=0;
> 		b=0;
> 		c=0;
> 		d=0;
> 		tmp=0;
> 		m=0;
> 		n=0;
> 		
> 	
> 	a=(int)date[0]-48;
> 	b=(int)date[2]-48;
> 	c=(int)date[4]-48;
> 	d=(int)date[6]-48;
> 	
> 	
> 	if(date[3]=='+')
> 		m=a*d+b*c;
> 	if(date[3]=='-')
> 		m=a*d-b*c;
> 	n=b*d;
> 
> 	tmp=gcd(m,n);
> 	m=m/tmp;
> 	n=n/tmp;
> 
> 	if(m%n<0)
> 	{	
> 		m=-1*m;
> 		printf("-%d/%d\n",m,n);
> 		continue;
> 	}
> 
> 	if(m%n==0)
> 	{ 
> 		if(m==0)
> 		{
> 			printf("0\n");
> 			continue;
> 		}
> 		else if(m<0)
> 		{
> 			m=-1*m;
> 			printf("-%d/%d\n",m,n);
> 			continue;
> 		}
> 		else printf("%d/%d\n",m,n);
> 	}
> 	printf("%d/%d\n",m,n);
> 	
> 	}
> 	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