Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪错了?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator