题目描述:
输入一个学生的信息,包括姓名、性别、年龄、体重,再输出该学生信息。
输入格式:
一行,依次是学生的姓名、性别、年龄、体重。
输出格式:
一行,依次是姓名、性别、年龄、体重(体重保留一位小数)。
样例输入:
wangfang f 20 48.6
样例输出:
wangfang f 20 48.6
提示:
定义一个student结构体:
- struct student{
-
- string name;
-
- char sex;
-
- int age;
-
- double weight;
-
- };
使用它:
student stu;
cin >> stu.name >> stu.sex >> stu.age >> stu.weight;
cout << stu.name << " "<< stu.sex << " " << stu.age << " ";
printf("%0.1lf", stu.weight );
时间限制: 1000ms
空间限制: 256MB
代码如下:
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- char a[101],b;
- int c;
- float d;
- cin>>a>>b>>c>>d;
- cout<<a<<" "<<b<<" "<<c<<" ";
- printf("%.1f",d);
- return 0;
- }