
求c++大神把下面的简单语句修改下,用cin,cout语句,替换printf的输入输出语句 20
#include<cstdio>#include<iostream>#include<cstring>#include<cmath>usingnamespacestd;c...
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
char s[105];
int ff=0;
int geta1()
{
int i;
int y=0;
for(i=0; s[i]; i++)if(s[i]=='/')
{
ff=1;
break;
}
int x=1;
for(int j=1; j<=i; j++)
{
if(s[i-j]=='-')
{
y=-y;
break;
}
y+=(s[i-j]-'0')*x;
x*=10;
}
return y;
}
int geta2()
{
int i;
for(i=0; s[i]; i++)if(s[i]=='/')
{
break;
}
int len;
len= strlen(s);
int x=1, y=0;
for(int j=len-1; j>i; j--)
{
if(s[j]=='-')
{
y=-y;
break;
}
y+=(s[j]-'0')*x;
x*=10;
}
return y;
}
int gcd(int a, int b){
if(a<b)swap(a,b);
return b==0 ?a:gcd(b, a%b);
}
void jia(int a, int b, int c, int d)
{
int gy;
gy=gcd(b, d);
int gb;
gb=b*d/gy;
a=gb/b*a;
c=gb/d*c;
int x, y;
x=a+c;
y=gb;
gy=gcd(abs(x), abs(y));
x/=gy;
y/=gy;
printf("答案:");
if(y!=1) printf("%d/%d\n", x, y);
else printf("%d\n", x);
}
void jian(int a, int b, int c, int d)
{
int gy;
gy=gcd(b, d);
int gb;
gb=b*d/gy;
a=gb/b*a;
c=gb/d*c;
int x, y;
x=a-c;
y=gb;
gy=gcd(abs(x), abs(y));
x/=gy;
y/=gy;
printf("答案:");
if(y!=1) printf("%d/%d\n", x, y);
else printf("%d\n", x);
}
void chen(int a, int b, int c, int d)
{
int gy;
gy=gcd(b, d);
int gb;
gb=b*d/gy;
a=gb/b*a;
c=gb/d*c;
int x, y;
x=a*c;
y=gb*gb;
gy=gcd(abs(x), abs(y));
x/=gy;
y/=gy;
printf("答案:");
if(y!=1) printf("%d/%d\n", x, y);
else printf("%d\n", x); 展开
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
char s[105];
int ff=0;
int geta1()
{
int i;
int y=0;
for(i=0; s[i]; i++)if(s[i]=='/')
{
ff=1;
break;
}
int x=1;
for(int j=1; j<=i; j++)
{
if(s[i-j]=='-')
{
y=-y;
break;
}
y+=(s[i-j]-'0')*x;
x*=10;
}
return y;
}
int geta2()
{
int i;
for(i=0; s[i]; i++)if(s[i]=='/')
{
break;
}
int len;
len= strlen(s);
int x=1, y=0;
for(int j=len-1; j>i; j--)
{
if(s[j]=='-')
{
y=-y;
break;
}
y+=(s[j]-'0')*x;
x*=10;
}
return y;
}
int gcd(int a, int b){
if(a<b)swap(a,b);
return b==0 ?a:gcd(b, a%b);
}
void jia(int a, int b, int c, int d)
{
int gy;
gy=gcd(b, d);
int gb;
gb=b*d/gy;
a=gb/b*a;
c=gb/d*c;
int x, y;
x=a+c;
y=gb;
gy=gcd(abs(x), abs(y));
x/=gy;
y/=gy;
printf("答案:");
if(y!=1) printf("%d/%d\n", x, y);
else printf("%d\n", x);
}
void jian(int a, int b, int c, int d)
{
int gy;
gy=gcd(b, d);
int gb;
gb=b*d/gy;
a=gb/b*a;
c=gb/d*c;
int x, y;
x=a-c;
y=gb;
gy=gcd(abs(x), abs(y));
x/=gy;
y/=gy;
printf("答案:");
if(y!=1) printf("%d/%d\n", x, y);
else printf("%d\n", x);
}
void chen(int a, int b, int c, int d)
{
int gy;
gy=gcd(b, d);
int gb;
gb=b*d/gy;
a=gb/b*a;
c=gb/d*c;
int x, y;
x=a*c;
y=gb*gb;
gy=gcd(abs(x), abs(y));
x/=gy;
y/=gy;
printf("答案:");
if(y!=1) printf("%d/%d\n", x, y);
else printf("%d\n", x); 展开
2个回答
2016-06-26
展开全部
printf("%d/%d\n", x, y); →cout<<x/y\n ;
printf("%d\n", x);→cout<<x\n;
printf("答案:");→cout<<"答案:";
printf("%d\n", x);→cout<<x\n;
printf("答案:");→cout<<"答案:";
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
按题目中粘贴的代码:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
char s[105];
int ff=0;
int geta1()
{
int i;
int y=0;
for(i=0; s[i]; i++)if(s[i]=='/')
{
ff=1;
break;
}
int x=1;
for(int j=1; j<=i; j++)
{
if(s[i-j]=='-')
{
y=-y;
break;
}
y+=(s[i-j]-'0')*x;
x*=10;
}
return y;
}
int geta2()
{
int i;
for(i=0; s[i]; i++)if(s[i]=='/')
{
break;
}
int len;
len= strlen(s);
int x=1, y=0;
for(int j=len-1; j>i; j--)
{
if(s[j]=='-')
{
y=-y;
break;
}
y+=(s[j]-'0')*x;
x*=10;
}
return y;
}
int gcd(int a, int b){
if(a<b)swap(a,b);
return b==0 ?a:gcd(b, a%b);
}
void jia(int a, int b, int c, int d)
{
int gy;
gy=gcd(b, d);
int gb;
gb=b*d/gy;
a=gb/b*a;
c=gb/d*c;
int x, y;
x=a+c;
y=gb;
gy=gcd(abs(x), abs(y));
x/=gy;
y/=gy;
cout << "答案:";
if(y!=1) cout << x << "/" << y << endl;
else cout << x << endl;
}
void jian(int a, int b, int c, int d)
{
int gy;
gy=gcd(b, d);
int gb;
gb=b*d/gy;
a=gb/b*a;
c=gb/d*c;
int x, y;
x=a-c;
y=gb;
gy=gcd(abs(x), abs(y));
x/=gy;
y/=gy;
cout << "答案:";
if(y!=1) cout << x << "/" << y << endl;
else cout << x << endl;
}
void chen(int a, int b, int c, int d)
{
int gy;
gy=gcd(b, d);
int gb;
gb=b*d/gy;
a=gb/b*a;
c=gb/d*c;
int x, y;
x=a*c;
y=gb*gb;
gy=gcd(abs(x), abs(y));
x/=gy;
y/=gy;
cout << "答案:";
if(y!=1) cout << x << "/" << y << endl;
else cout << x << endl;
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
char s[105];
int ff=0;
int geta1()
{
int i;
int y=0;
for(i=0; s[i]; i++)if(s[i]=='/')
{
ff=1;
break;
}
int x=1;
for(int j=1; j<=i; j++)
{
if(s[i-j]=='-')
{
y=-y;
break;
}
y+=(s[i-j]-'0')*x;
x*=10;
}
return y;
}
int geta2()
{
int i;
for(i=0; s[i]; i++)if(s[i]=='/')
{
break;
}
int len;
len= strlen(s);
int x=1, y=0;
for(int j=len-1; j>i; j--)
{
if(s[j]=='-')
{
y=-y;
break;
}
y+=(s[j]-'0')*x;
x*=10;
}
return y;
}
int gcd(int a, int b){
if(a<b)swap(a,b);
return b==0 ?a:gcd(b, a%b);
}
void jia(int a, int b, int c, int d)
{
int gy;
gy=gcd(b, d);
int gb;
gb=b*d/gy;
a=gb/b*a;
c=gb/d*c;
int x, y;
x=a+c;
y=gb;
gy=gcd(abs(x), abs(y));
x/=gy;
y/=gy;
cout << "答案:";
if(y!=1) cout << x << "/" << y << endl;
else cout << x << endl;
}
void jian(int a, int b, int c, int d)
{
int gy;
gy=gcd(b, d);
int gb;
gb=b*d/gy;
a=gb/b*a;
c=gb/d*c;
int x, y;
x=a-c;
y=gb;
gy=gcd(abs(x), abs(y));
x/=gy;
y/=gy;
cout << "答案:";
if(y!=1) cout << x << "/" << y << endl;
else cout << x << endl;
}
void chen(int a, int b, int c, int d)
{
int gy;
gy=gcd(b, d);
int gb;
gb=b*d/gy;
a=gb/b*a;
c=gb/d*c;
int x, y;
x=a*c;
y=gb*gb;
gy=gcd(abs(x), abs(y));
x/=gy;
y/=gy;
cout << "答案:";
if(y!=1) cout << x << "/" << y << endl;
else cout << x << endl;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询