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 20091895 at 2011-02-28 22:14:27 on Problem 3979
#include <stdio.h>
void yue(int z,int m)
{
	int max;
	int i;
	if(z<0)
	{z=-z;
	for(i=1;i<=z;i++)
	{
		if(z%i==0)
		{
			if(m%i==0)
				max=i;
		}
		
	}
	z=z/max;
	m=m/max;
	if(z==m)
		printf("-j%d\n",z);
	else
		printf("-%d/%d\n",z,m);
	}
	else
	{
		for(i=1;i<=z;i++)
		{
			if(z%i==0)
			{
				if(m%i==0)
					max=i;
			}
			
		}
		z=z/max;
		m=m/max;
		if(z==m)
			printf("%d\n",z);
		else
			printf("%d/%d\n",z,m);
	}
}

int main()
{
	int a,b,c,d,z,m;
	char o,p,q;
	scanf("%d%c%d%c%d%c%d",&a,&p,&b,&o,&c,&q,&d);
	switch(o)
	{
	case '+':(m = (b*d))&&(z = (a*d+c*b));break;
	case '-':(m = (b*d))&&(z = (a*d-c*b));break;
	default:printf("输入错误!\n");
	}
	yue(z,m);
	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