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 blank_bird at 2011-02-19 02:01:22 on Problem 3979
In Reply To:怎么总是编译错误? Posted by:blank_bird at 2011-02-19 01:00:53
> #include<stdio.h>
> #include<string.h>
> #include<stdlib.h>
> int gcd(int a,int b)//求最大公约数
> {
> 	int t;
> 	if(a<b)
> 	{
> 		t=a;
> 		a=b;
> 		b=t;
> 	}
> 	if(a%b==0)return b;
> 	else
> 		return gcd(b,a%b);
> }
> int min(int a,int b)//求最小公倍数
> {
> 	return a*(b/gcd(a,b));
> }
> void bb(char * str,int *n,int *m)
> {
> 	int a,b,c,d,e;
> 	char ch;
> 	ch=str[3];
> 	a=str[0]-'0';
> 	b=str[2]-'0';
> 	c=str[4]-'0';
> 	d=str[6]-'0';
> 	e=min(b,d);
> 	a=a*(e/b);
> 	c=c*(e/d);
> 	*m=e;
> 	if(ch=='+') *n=a+c;
> 	if(ch=='-') *n=a-c;
> 	return ;
> }
> void out(int a,int b)
> {
> 	int c;
> 	if(a==0){printf("%d\n",0);return ;}
> 	 c=gcd(a,b);
> 	if(c<0)c=-c;
> 	a=a/c;
> 	b=b/c;
> 	if(a==b){printf("%d\n",1);return ;}
> 	if(b==1){printf("%d\n",a);return ;}
> 	printf("%d/%d\n",a,b);
> 	return ;
> 
> }
> int main(void)
> {
> 	char str[20][10]={'\0'};
> 	int a[20]={0},b[20]={0},i=0,n;
> 	while(scanf("%s",str[i])!=EOF)
> 	{
> 		bb(str[i],&a[i],&b[i]);
> 		i++;
> 	}
> 	n=i;
> 	for(i=0;i<n;i++)
> 		out(a[i],b[i]);
> 	return 1;
> 
> }

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