从键盘输入双精度给变量X和Y,输出X和Y,再交换X和Y的值后输出X和Y
展开全部
#include<stdio.h>
void swap(double &a,double &b)
{a=a+b;b=a-b;a=a-b;}
main()
{
double a,b;
scanf("%f,%f",&a,&b);
printf("%f,%f\n",a,b);
swap(a,b);
printf("%f,%f\n",a,b);
}
void swap(double &a,double &b)
{a=a+b;b=a-b;a=a-b;}
main()
{
double a,b;
scanf("%f,%f",&a,&b);
printf("%f,%f\n",a,b);
swap(a,b);
printf("%f,%f\n",a,b);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
c++做法:
#include<iostream>
using namespace std;
int main()
{
double x,y,t;
cin>>x>>y;
cout<<x<<" "<<y<<endl;
x=t;
x=y;
y=t;
cout<<x<<" "<<y<<endl;
system("pause");
return 0;
}
#include<iostream>
using namespace std;
int main()
{
double x,y,t;
cin>>x>>y;
cout<<x<<" "<<y<<endl;
x=t;
x=y;
y=t;
cout<<x<<" "<<y<<endl;
system("pause");
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2009-03-22
展开全部
#include <stdio.h>
int main()
{
double x, y;
double temp;
printf("input two Numbers: ");
scanf("%lf %lf", &x, &y);
printf("%lf, %lf\n", x, y);
temp = x;
x = y;
y = temp;
printf("%lf, %lf\n", x, y);
}
int main()
{
double x, y;
double temp;
printf("input two Numbers: ");
scanf("%lf %lf", &x, &y);
printf("%lf, %lf\n", x, y);
temp = x;
x = y;
y = temp;
printf("%lf, %lf\n", x, y);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
交换输出的话先输出y再输出x就行了.这个太简单了.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询