#include<iostream>
using namespace std;
class Cylinder{
public:
float radius;
float height;
float V;
void read(){
float a,b;
cin >> a >> b;
radius = a,height = b;
}
void get_V(){
V = 3.1415926 * height * radius * radius;
}
void print_data(){
cout << "底圆半径:" << radius << " 高 :" << height << " 体积为: " << V << endl;
}
};
int main(){
Cylinder a;
a.read();
a.get_V();
a.print_data();
return 0;
}
#include<iostream>
using namespace std;
class My_String{
public:
string content;
int len;
void set(){
cin >> content;
}
void show(){
cout << " 字符串为: " << content << endl;
}
void get_len(){
len = content.size();
}
void add_string(string b){
content += b;
}
void add_string2(){
string c;
cout << " 请输入你要在原字符串连接的字符串: " << endl;
cin >> c;
content += c;
}
};
int main(){
My_String a;
a.set();
a.get_len();
a.show();
a.add_string2();
a.show();
return 0;
}
#ifndef _STUDENT_H_
#define _STUDENT_H_
#include<iostream>
#include<string>
using namespace std;
class Student{
public:
string number;
string name;
string sex;
void set();
void display();
};
#endif
#include"student.h"
#include<iostream>
using namespace std;
void Student::set(){
string aa,bb,cc;
cout << "input Student's number ,name and sex: " << endl;
cin >> aa >> bb >> cc;
Student::number = aa;
Student::name = bb;
Student::sex = cc;
}
void Student::display(){
cout << " 学生的学号是: " << Student::number << " 学生的姓名是: " << Student::name << " 学生的性别是: " << Student::sex << endl;
}
#include"student.h"
#include<iostream>
using namespace std;
int main(){
Student a;
a.set();
a.display();
return 0;
}