7-6 混合类型数据格式化输入 (5 分)

版权声明: https://blog.csdn.net/rjf666/article/details/83301687

7-6 混合类型数据格式化输入 (5 分)

本题要求编写程序,顺序读入浮点数1、整数、字符、浮点数2,再按照字符、整数、浮点数1、浮点数2的顺序输出。

输入格式:

输入在一行中顺序给出浮点数1、整数、字符、浮点数2,其间以1个空格分隔。

输出格式:

在一行中按照字符、整数、浮点数1、浮点数2的顺序输出,其中浮点数保留小数点后2位。

输入样例:

2.12 88 c 4.7

输出样例:

c 88 2.12 4.70
 #include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
int main(void)
{
	int a;
	char c;
	float p, q;
	
	scanf("%f %d %c %f", &p, &a, &c, &q);
	printf("%c %d %.2f %.2f", c, a, p, q);
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/rjf666/article/details/83301687
今日推荐