# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<fstream>
using namespace std;


bool SHH(int n);

int main(){
// doc file
	ifstream find;
	find.open("NUMBER.INP");
	if(find.fail()){
		cout << "Ko mo file thanh cong !";
		return 0;
	}
	int n;
	find >> n;
//	cout << n;
	find.close();
// ghi file
	ofstream fout;
	fout.open("NUMBER.OUT");
	if(fout.fail()){
		cout << "Khong tao file thanh cong!";
		return 0;
	}
	for(int i = 2; i < n; i++){
		if(SHH(i) == true){
			fout << i << endl;
		}
	}
	
	cout << "Mo file NUMBER.OUT de xem ket qua!";
	fout.close();
	
}


bool SHH(int n){
	int tong = 1;
	for(int i = 2; i < n; i++){
		if(n % i == 0){
			tong += i; // check tong
		}
	}
	if(tong == n){
		return true;
	}
	else{
		return false;
	}
}

# data[].attributes.attachment_link.readable_text
void SapXep(int A[], int Left, int m, int Right)
{
    int i, j, k;
    int n1 = m - Left + 1;
    int n2 =  Right - m;
 
    
    int B[n1], C[n2];
 
    
    for (i = 0; i < n1; i++)
        B[i] = A[Left + i];
    for (j = 0; j < n2; j++)
        C[j] = A[m + 1+ j];
 
   
    i = 0; 
    j = 0; 
    k = Left; 
    while (i < n1 && j < n2)
    {
        if (B[i] <= C[j])
        {
            A[k] = B[i];
            i++;
        }
        else
        {
            A[k] = C[j];
            j++;
        }
        k++;
    }
 
    
    while (i < n1)
    {
        A[k] = B[i];
        i++;
        k++;
    }
 
   
    while (j < n2)
    {
        A[k] = C[j];
        j++;
        k++;
    }
}
 

void kiemTra(int A[], int Left, int Right) // ham so sanh de dung ham de qui
{
    if (Left < Right)
    {
        
        int m = Left+(Right-Left)/2;
 
        
        kiemTra(A, Left, m);
        kiemTra(A, m+1, Right);
        SapXep(A, Left, m, Right);
    }
}
 
 
// Ham xuat mang
void inDL(int A[], int size)
{
    for (int i=0; i < size; i++){
    	cout << A[i] << endl;
	}
        
}
 

# data[].attributes.attachment_link.readable_text
#include<iostream>
#include<string>
#define SIZE 100


using namespace std;

struct sach{
	string maSach; // co the dung kieu char
	string tenSach;
	string tacGia;
	double giaSach;
};

void nhapDL(sach A[SIZE], int &n); // n la so luong cuon sach 
void inDL(sach A[SIZE], int n);


int main(){
	sach A[SIZE];
	int n;
	nhapDL(A,n);
	inDL(A,n);
	
	return 0;
}


void nhapDL(sach A[SIZE], int &n){
	cout << "Nhap vao so luong cuon sach: " << endl;
	cin >> n;
	cout << endl;
	for(int i=0; i<n; i++){
		cout << "Nhap thong tin cuon sach thu " << i+1 << " : " << endl;
		cin.ignore();
		cout << "Nhap ma sach: ";
		getline(cin, A[i].maSach);
		cout << "Nhap ten sach: ";
		getline(cin, A[i].tenSach);
		cout << "Nhap tac gia: ";
		getline(cin, A[i].tacGia);
		cout << "Nhap gia sach: ";
		cin >> A[i].giaSach;
	}
}

void inDL(sach A[SIZE], int n){
	cout << "Thong tin cuon sach da nhap la: ";
	for(int i=0; i<n; i++){
		cout << "Cuon sach thu " << i+1 << " da nhap la: " << endl;
		cout << "Ma sach: " << A[i].maSach << endl;
		cout << "Ten sach: " << A[i].tenSach << endl;
		cout << "Tac gia: " << A[i].tacGia << endl;
		cout << "Gia sach: " << A[i].giaSach << endl;
		cout << endl;
	}
}
