Fjf

Bla bla
Last edited on
hello xie^n

#include <iostream>
#include <string>

using namespace std;

struct Person{
string lastName, firstName;
int age;
Person(string _lastName,string _firstName){
lastName = _lastName;
firstName = _firstName;
}
void setAge(int n){
age = n;
}
string getFullName(){
string f = firstName + lastName;
return f;
}
int getAge(){
return age;
}
};




int main() {
//Nhap vao ho, ten va tuoi
string lastName, firstName;
int age;
cin >> lastName >> firstName >> age;
//Khai bao va khoi tao 1 nguoi voi ten, ho
Person person(lastName, firstName);
//Dat tuoi cho nguoi nay
person.setAge(age);
//In ra ho ten day du va tuoi cua nguoi do
cout << person.getFullName() << ", " << person.getAge();

return 0;
}
Last edited on
lỗi r
dua cai using namespace std len tren, t viet nham cho
sua r day

m phai cho t cai test de t xem no yeu cau ntn
lúc in ra thiếu dấu cách
Input Description
Nguyen An 20
Tran Hung 19

Output Description
Nguyen An, 20
Tran Hung, 19

#include <iostream>
#include <string>

using namespace std;


struct Person{
string lastName, firstName;
int age;
Person(string _lastName,string _firstName){
lastName = _lastName;
firstName = _firstName;
}
void setAge(int n){
age = n;
}
string getFullName(){
string f = firstName + " " + lastName;
return f;
}
int getAge(){
return age;
}
};




int main() {
//Nhap vao ho, ten va tuoi
string lastName, firstName;
int age;
cin >> lastName >> firstName >> age;
//Khai bao va khoi tao 1 nguoi voi ten, ho
Person person(lastName, firstName);
//Dat tuoi cho nguoi nay
person.setAge(age);
//In ra ho ten day du va tuoi cua nguoi do
cout << person.getFullName() << ", " << person.getAge();

return 0;
}
vẫn 0đ
m phai cho t cai test cua no de t xem no in ra nhu nao

#include <iostream>
#include <string>

using namespace std;


struct Person{
string lastName, firstName;
int age;
Person(string _lastName,string _firstName){
lastName = _lastName;
firstName = _firstName;
}
void setAge(int n){
age = n;
}
string getFullName(){
string f = lastName + " " + firstName;
return f;
}
int getAge(){
return age;
}
};




int main() {
//Nhap vao ho, ten va tuoi
string lastName, firstName;
int age;
cin >> lastName >> firstName >> age;
//Khai bao va khoi tao 1 nguoi voi ten, ho
Person person(lastName, firstName);
//Dat tuoi cho nguoi nay
person.setAge(age);
//In ra ho ten day du va tuoi cua nguoi do
cout << person.getFullName() << ", " << person.getAge();

return 0;
}
Topic archived. No new replies allowed.