从键盘输入双精度给变量X和Y,输出X和Y,再交换X和Y的值后输出X和Y
展开全部
#include <stdio.h>
#include <stdlib.h>
int main()
{
double x, y;
double temp; //这个变量用来临时存放需要交换的值
printf("please input x: ");
scanf("%lf", &x);
printf("please input x: ");
scanf("%lf", &y);
printf("yue are x and y: %f, %f\n", x, y);
//开始交换数据的三行代码
temp = x;
x = y;
y = temp;
//**************
printf("swaped x and y: %f, %f\n", x, y);
getchar();
//getchar();
return(0);
}
#include <stdlib.h>
int main()
{
double x, y;
double temp; //这个变量用来临时存放需要交换的值
printf("please input x: ");
scanf("%lf", &x);
printf("please input x: ");
scanf("%lf", &y);
printf("yue are x and y: %f, %f\n", x, y);
//开始交换数据的三行代码
temp = x;
x = y;
y = temp;
//**************
printf("swaped x and y: %f, %f\n", x, y);
getchar();
//getchar();
return(0);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#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);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
饿.....
void main()
{
float x,y,z;
scanf("%f%f",&x,&y);
printf("\n交换前x=%f,y=%f\n",x,y);
//交换
z=x;
x=y;
y=z;//这样就交换了
printf("\n交换后x=%f,y=%f\n",x,y);
}
void main()
{
float x,y,z;
scanf("%f%f",&x,&y);
printf("\n交换前x=%f,y=%f\n",x,y);
//交换
z=x;
x=y;
y=z;//这样就交换了
printf("\n交换后x=%f,y=%f\n",x,y);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<srdio.h>
viod main()
{
double x,y,a;
scanf("%lf %lf",&x,&y);
a=x;
x=y;
y=a;
printf("%lf, %lf\n", x, y);
}
viod main()
{
double x,y,a;
scanf("%lf %lf",&x,&y);
a=x;
x=y;
y=a;
printf("%lf, %lf\n", x, y);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <stdio.h>
void swap(double &x, double &y)
{
double temp = 0.0;
temp = y;
y = x;
x = temp;
}
void main()
{
double x = 0.0,y = 0.0;
scanf("%lf %lf",&x,&y);
printf("%lf\t%lf\n",x,y);
swap(x,y);
printf("%lf\t%lf\n",x,y);
}
void swap(double &x, double &y)
{
double temp = 0.0;
temp = y;
y = x;
x = temp;
}
void main()
{
double x = 0.0,y = 0.0;
scanf("%lf %lf",&x,&y);
printf("%lf\t%lf\n",x,y);
swap(x,y);
printf("%lf\t%lf\n",x,y);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询