C语言顺序读入浮点1、整数、字符、浮点数2,在按照字符、整数、浮点数1浮点数2的顺序输出,浮点保留小数点后两位
时间: 2023-12-27 08:03:02 浏览: 33
```c
#include <stdio.h>
int main() {
float f1, f2;
int i;
char c;
// 读入四个变量
scanf("%f %d %c %f", &f1, &i, &c, &f2);
// 输出四个变量
printf("%c %d %.2f %.2f", c, i, f1, f2);
return 0;
}
```
相关问题
顺序读入浮点数1、整数 字符 浮点数二 再按照字符整数浮点数1浮点数2的顺序输出
代码如下:
```python
f1 = float(input()) # 读入浮点数1
i1 = int(input()) # 读入整数
c = input() # 读入字符
f2 = float(input()) # 读入浮点数2
print(c, i1, f1, f2) # 按照字符整数浮点数1浮点数2的顺序输出
```
输入示例:
```
3.14
42
A
2.718
```
输出示例:
```
A 42 3.14 2.718
```
顺序读入浮点1、整数、字符、浮点数2,在按照字符、整数、浮点数1浮点数2的顺序输出,浮点保留小数点后两位
示例输入:
```
3.14
100
a
2.718
```
示例输出:
```
a 100 3.14 2.72
```
代码实现:
```python
# 读入浮点1、整数、字符、浮点数2
f1 = float(input())
n = int(input())
c = input()
f2 = float(input())
# 输出
print(c, n, format(f1, '.2f'), format(f2, '.2f'))
```
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)