0% found this document useful (0 votes)
7 views4 pages

Ktra

a

Uploaded by

nguyencanhson789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Ktra

a

Uploaded by

nguyencanhson789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

#include <iostream>

#include <string>

using namespace std;

class CongDan {

private:

string cccd;

string hoten;

int tuoi;

string nghe;

string quocTich;

public:

void nhap() {

cout << "Nhap so CCCD: ";

getline(cin, soCCCD);

cout << "Nhap ho ten: ";

getline(cin, hoTen);

cout << "Nhap tuoi: ";

cin >> tuoi;

cin.ignore();

cout << "Nhap nghe nghiep: ";

getline(cin, ngheNghiep);

cout << "Nhap quoc tich: ";

getline(cin, quocTich);

void in() {

cout << "So CCCD: " << soCCCD << endl;


cout << "Ho ten: " << hoTen << endl;

cout << "Tuoi: " << tuoi << endl;

cout << "Nghe nghiep: " << ngheNghiep << endl;

cout << "Quoc tich: " << quocTich << endl;

string getngheNghiep() const {

return ngheNghiep;

int getTuoi() const {

return tuoi;

string getQuocTich() const {

return quocTich;

string getCCCD() const {

return cccd;

void setngheNghiep(string newngheNghiep) {

ngheNghiep = newngheNghiep;

};

void nhapDanhsach(CongDan cd[], int n) {

for (int i = 0; i < n; i++) {


cout << "Nhap thong tin cong dan thu " << i + 1 << ":\n";

cd[i].nhap();

cout << endl;

void inDanhsach(CongDan cd[], int n )

for (int i =0; i <n; i++)

cd[i].in();

cout<<endl;

void sapXepTuoi(CongDan cd[], int n)

for(int i = 0; i < n-1; i++)

for(int j = i+1; j < n; j++)

if(cd[i].getTuoi() > cd[j].getTuoi())

swap(cd[i], cd[j]);

void inCongDanBacSy(CongDan cd[], int n) {

for (int i = 0; i < n; i++) {

if (cd[i].getNgheNghiep() == "Bac sy") {

cd[i].in();

cout << endl;

}
}

void inQuocTich(CongDan cd[], int n, string quocTich) {

for (int i = 0; i < n; i++) {

if (cd[i].getQuocTich() == quocTich) {

cd[i].in();

cout << endl;

You might also like