# data[].attributes.body
+2x^15 -1x^10 +x^7 +x^5 -x^4 +6x^2 -8.5x^1 -10.52x^0

Don Thuc: [HeSo]x^[SoMu]

+ HeSo:

0: Khong Xuat nguyen ca DonThuc

1: + (Khong Xuat Heso)

-1: - (Khong Xuat heSo)

>1: + Xuat het (He so cua DonThuc Dau tien)

<-1: Xuat het

+ So Mu:

0: Khong xuat gi het (x^[SoMu])

1: x

>1: x^[SoMu]

*/

void Xuat(DONTHUC &A, int i){

if(A.heSo==0) return;

else if(A.heSo==1) cout << "+";

else if(A.heSo==-1) cout << "-";

else if(A.heSo>1) {

if(i!=0) cout << "+";

cout << A.heSo; }

else if(A.heSo<-1) cout << A.heSo;

if(A.soMu==0) return;

else if(A.soMu==1) cout << "x";

else cout << "x^" << A.soMu;

}

# data[].attributes.body
#include <bits/stdc++.h>

using namespace std;

struct DONTHUC {

double heSo;

int soMu;

};

struct DATHUC {

DONTHUC arr[101];

int soLuong;

};

void Nhap(DONTHUC &A){ cin >> A.heSo >> A.soMu; }

DATHUC *Nhap() {

DATHUC *B = new DATHUC;

cin >> B->soLuong;

for (int i = 0; i < B->soLuong; i++)

Nhap(B->arr[i]);

return B;

}

void Xuat(DONTHUC &A){

cout << A.heSo << A.soMu << endl;

}

void Xuat(DATHUC A){

cout << A.soLuong;

for (int i = 0; i < A.soLuong; i++)

Xuat(A.arr[i]);

}

int main() {

DATHUC *B;

B = Nhap();

cout << "Da thuc vua nhap la: ";

Xuat(*B);

/* double x; cin >> x;

cout << "\nVoi x=" << x << ", gia tri da thuc la: "

<< setprecision(2) << fixed << TinhDaThuc(*B, x);

*/

return 0;

}

# data[].attributes.headline
11/12/2024 - Mang chuoi ===> Thêm cin.ignore vào sau khi nhập n

# data[].attributes.subject
11/12/2024 - Mang chuoi ===> Thêm cin.ignore vào sau khi nhập n

# data[].attributes.body
#include <bits/stdc++.h>

using namespace std;

#define MAXR 10

#define MAXC 1000

void Solve(){

char **str = new char*[MAXC];

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

str[i] = new char[MAXR];

int n;

cin >> n;

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

cout << i << " ";

cin.getline(str[i], MAXR);

}

cout << "------------";

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

cout << str[i] << endl;

}

int main(){Solve();}

/*

CNVN2

HTTT

KHMT

CNTN

CNPM

*/

# data[].attributes.body
#include <iostream>

#include <cstring>

using namespace std;

#define MAXN 100

void NhapChuoi(char *a) {

cin.getline(a, MAXN);

}

void TachHoTen(char hoten, char ho, char *ten) {

int i=0, j=0;

while(hoten[i]!=' ' && hoten[i]!='\0')

ho[j++]=hoten[i++];

ho[j]='\0';

while (hoten[i]==' ')

i++;

j=0;

while (hoten[i]!='\0')

ten[j++]=hoten[i++];

ten[j]='\0';

}

int main() {

int arr[5]={11, 32, 13, 40, 6};

int *parr=&arr[2];// arr+2

parr++;

cout << &parr << " " << parr << endl;

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

cout << arr+i << " ";// &arr[i]

cout << endl;

cout << *(parr-2) << " ";

cout << *(parr-1) << " ";

cout << *(parr+0) << " ";

cout << *(parr+1) << " ";

cout << *(parr+2) << " ";

return 0;

}

# data[].attributes.body
#include <iostream>

#include <cstring>

using namespace std;

#define MAXN 100

void NhapChuoi(char *a) {

cin.getline(a, MAXN);

}

void TachHoTen(char hoten, char ho, char *ten) {

int i=0, j=0;

while(hoten[i]!=' ' && hoten[i]!='\0')

ho[j++]=hoten[i++];

ho[j]='\0';

while (hoten[i]==' ')

i++;

j=0;

while (hoten[i]!='\0')

ten[j++]=hoten[i++];

ten[j]='\0';

}

int main() {

int a=8;

char kt='a';

int *p;

cout << "a: " << &a << " " << a << endl;

cout << "kt: " << (void*)&kt << " " << kt << endl;

cout << "p: " << &p << " " << p << endl;

p=&a;

cout << "p: " << &p << " " << p << " " << *p << endl;

char *p1=&kt;

cout << "p1: " << &p1 << " " << p1 << " " << *p1 << endl;

return 0;

}

# data[].attributes.body
#include <iostream>

#include <cstring> // string.h

using namespace std;

#define MAXN 100

void NhapChuoi(char *a) {

cin.getline(a, MAXN);

}

void TachHoTen(char hoten, char ho, char *ten) {

int i=0, j=0;

while(hoten[i]!=' ' && hoten[i]!='\0')

ho[j++]=hoten[i++];

ho[j]='\0';

while (hoten[i]==' ')

i++;

j=0;

while (hoten[i]!='\0')

ten[j++]=hoten[i++];

ten[j]='\0';

}

int main() {

char hoten[MAXN]="Nguyen Ngoc Lan", ho[MAXN], chulot[MAXN], ten[MAXN];

std::cout << hoten << endl;

char *vt=strchr(hoten, ' ');

strcpy(ten, hoten+12);

strncpy(ho, hoten, 6);

strncpy(chulot, hoten+7, 4);

// TachHoTen(hoten, ho, ten);

cout << "vt: " << vt << '\n';

cout << "ho: " << ho << '\n';

cout << "chulot: " << chulot << '\n';

cout << "ten: " << ten << '\n';

return 0;

}

# data[].attributes.body
#include <iostream>

#include <cstring>

using namespace std;

#define MAXN 100

void NhapChuoi(char *a) {

cin.getline(a, MAXN);

}

void TachHoTen(char hoten, char ho, char *ten) {

int i=0, j=0;

while(hoten[i]!=' ' && hoten[i]!='\0')

ho[j++]=hoten[i++];

ho[j]='\0';

while (hoten[i]==' ')

i++;

j=0;

while (hoten[i]!='\0')

ten[j++]=hoten[i++];

ten[j]='\0';

}

int main() {

char hoten[MAXN]="Nguyen Ngoc Lan", ho[MAXN], ten[MAXN];

std::cout << hoten << endl;

TachHoTen(hoten, ho, ten);

cout << ho << '\n';

cout << ten << '\n';

return 0;

}

# data[].attributes.body
#include <iostream>

#include <cstring>

using namespace std;

#define MAX 100

// int Search(double a[], int n, int x){

// int Search(double a[MAX], int n, int x){

int Search(double *a, int n, int x){

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

if (a[vt] == x) return vt+1;

return -1;

}

int main() {

double a[MAX];

int n=5;

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

a[i]=i+5;

int x; cin >> x;

cout << Search(a, n, x);

return 0;

}

# data[].attributes.body
#include <iostream>

#include <cstring>

using namespace std;

#define MAX 100

int main() {

int arr[MAX];

int n;

cin >> n;

int x;

cin >> x;

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

{

cin >> arr[i];

}

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

{

if (arr[i] == x)

{

cout << "arr["<<i<<"]= " << arr[i];

break;

}

}

return 0;

}

# data[].attributes.body
#include <bits/stdc++.h>

using namespace std;

//Nguyen Hung Phong

long long GiaiThuaDeQuy(long long b){

if (b <= 1) return 1;

else{

return b*GiaiThuaDeQuy(b-1);

}

}

long long GiaiThuaVongLap(long long c){

if (c == 0) return 1;

long long result = 1;

for (long long i = 1; i <= c;i++){

result *= i;

}

return result;

}

int main()

{

long long a;

cin >> a;

cout << "Giai thua voi de quy: " << GiaiThuaDeQuy(a) << endl;

cout << "Giai thua voi vong lap: " << GiaiThuaVongLap(a);

return 0;

}

# data[].attributes.body
#include <bits/stdc++.h>

using namespace std;

//Nguyen Hung Phong

long long GiaiThuaDeQuy(long long b){

if (b <= 1) return 1;

else{

return b*GiaiThuaDeQuy(b-1);

}

}

long long GiaiThuaVongLap(long long c){

if (c == 0) return 1;

long long result = 1;

for (long long i = 1; i <= c;i++){

result *= i;

}

return result;

}

int main()

{

long long a;

cin >> a;

cout << "Giai thua voi de quy: " << GiaiThuaDeQuy(a) << endl;

cout << "Giai thua voi vong lap: " << GiaiThuaVongLap(a);

return 0;

}

# data[].attributes.body
#include <bits/stdc++.h>

using namespace std;

//Nguyen Hung Phong

int GiaiThuaDeQuy(int b){

if (b <= 1) return 1;

else{

return b*GiaiThuaDeQuy(b-1);

}

}

int GiaiThuaVongLap(int c){

int result = 1;

for (int i = 1; i <= c;i++){

result *= i;

}

return result;

}

int main()

{

int a;

cin >> a;

cout << "Giai thua voi de quy: " << GiaiThuaDeQuy(a) << endl;

cout << "Giai thua voi vong lap: " << GiaiThuaVongLap(a);

return 0;

}

# data[].attributes.body
#include<iostream>

using namespace std;

void Input(int &x){ cin >> x; }

int Input(){

int x;

cin >> x;

return x;

}

void Max(const int &a1, const int &b1, int &maxX){

maxX = a1 > b1 ? a1 : b1;

}

int Max (const int &a, const int &b){

return (a > b ? a : b);

}

int GiaiThua(int x){

int i=1, gt=1;

while(i<=x){

gt *= i;

i++;

}

return gt;

}

void GiaiThua(int x, long long &gt){

int i=1;

gt=1;

while(i<=x){

gt*=i;

i++;

}

}

int main () {

int a, b;

long long kq;

Input(a);

Input(b);

cout << GiaiThua(a) << endl;

GiaiThua(b, kq);

cout << kq << endl;

return 0;

}

# data[].attributes.body
#include <iostream>

#include <cstring>

using namespace std;

#define MAXN 100

void NhapChuoi(char *a) {

cin.getline(a, MAXN);

}

void TachHoTen(char hoten, char ho, char *ten) {

int i=0, j=0;

while(hoten[i]!=' ' && hoten[i]!='\0')

ho[j++]=hoten[i++];

ho[j]='\0';

while (hoten[i]==' ')

i++;

j=0;

while (hoten[i]!='\0')

ten[j++]=hoten[i++];

ten[j]='\0';

}

int main() {

int arr[5]={11, 32, 13, 40, 6};

int *parr=&arr[0];// arr

cout << &parr << " " << parr << endl;

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

cout << &arr[i] << " ";

cout << endl;

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

cout << parr[i] << " ";

return 0;

}