Chào các bạn! Vì nhiều lý do từ nay Truyen2U chính thức đổi tên là Truyen247.Pro. Mong các bạn tiếp tục ủng hộ truy cập tên miền mới này nhé! Mãi yêu... ♥

toan C++

Giai pt bac hai:

#include <iostream.h>

#include <conio.h>

#include <math.h>

void giai_pt(float a,float b,float c)

{float delta,x,x1,x2;

if (a==0)

{x=-c/b;

cout<<"pt da cho tro thanh phuong trinh bac nhat :

";

cout<<"pt da cho co nghiem la x = "<<x;

}

else

{

delta=(b*b)-(4*a*c);

if (delta<0)

{

cout<<"pt da cho vo nghiem :

";

}

else if (delta>0)

{

x1=(-b-sqrt(delta))/2*a;

x2=(-b+sqrt(delta))/2*a;

cout<<"pt da cho co 2 nghiem phan biet x1 va x2

";

cout<<"x1 = "<<x1<<"

";

cout<<"x2 = "<<x2<<"

";

}

else if (delta==0)

{

cout<<"pt co nghiem kep x1=x2=x

";

x=-b/(2*a);

cout<<"x = "<<x;

}

}

}

main()

{

float a,b,c,d,x1,x2;

cout<<"nhap vao he so a : ";cin>>a;

cout<<"nhap vao he so b : ";cin>>b;

cout<<"nhap vao he so c : ";cin>>c;

giai_pt(a,b,c);

getch();

}

Giai PTB2 (ham)

#include <iostream.h>

#include <conio.h>

#include <math.h>

void giai_pt(float a,float b,float c)

{

float delta,x,x1,x2;

if (a==0)

{

x=-c/b;

cout<<"pt da cho tro thanh phuong trinh bac nhat :

";

cout<<"pt da cho co nghiem la x = "<<x;

}

else

{

delta=(b*b)-(4*a*c);

if (delta<0)

{

cout<<"pt da cho vo nghiem :

";

}

else if (delta>0)

{

x1=(-b-sqrt(delta))/2*a;

x2=(-b+sqrt(delta))/2*a;

cout<<"pt da cho co 2 nghiem phan biet x1 va x2

";

cout<<"x1 = "<<x1<<"

";

cout<<"x2 = "<<x2<<"

";

}

else if (delta==0)

{

cout<<"pt co nghiem kep x1=x2=x

";

x=-b/(2*a);

cout<<"x = "<<x;

}

}

}

main()

{

float a,b,c,d,x1,x2;

cout<<"nhap vao he so a : ";cin>>a;

cout<<"nhap vao he so b : ";cin>>b;

cout<<"nhap vao he so c : ";cin>>c;

giai_pt(a,b,c);

getch();

}

Ma tran chuyen vi (ham)

#include <iostream.h>

#include <conio.h>

#include <iomanip.h>

void nhap_matran(int a[][30],int n)

{

int i,j;

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

for (j=0;j<n;j++)

{

cout<<"a["<<i<<","<<j<<"] = ";cin>>a[i][j];

}

}

void hoan_vi(int a[][30],int n)

{

int i,j;

for (j=0;j<n;j++)

{

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

a[n][n]=a[j][i];

}

}

void in_ketqua(int a[][30],int n)

{

int i,j;

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

{

for (j=0;j<n;j++)

cout<<setw(4)<<a[j][i];cout<<endl;

}

}

main()

{

int a[30][30],n;

cout<<"nhap vao n : ";cin>>n;

nhap_matran(a,n);

hoan_vi(a,n);

in_ketqua(a,n);

getch();

}

Chuyê n ky t°# âu dong thanh hoa

Va sp xêp theo vân anpha

#include <iostream.h>

#include <ctype.h>

#include <conio.h>

#include <string.h>

main()

{

char tam,s[50];

int f = 0,i;

cout<<"moi ban nhap vao chuoi can chuyen : ";cin.getline(s,50);

for (i=0;i<strlen(s);i++)

{

if (s[i] != ' '&& f==0)

{

s[i]=toupper(s[i]);

f = 1;

}

else

{

s[i]=tolower(s[i]);

if(s[i] == ' ') f=0;

}

}

s[i]='\0';

cout<<s<<endl;

}

Tinh giai thua Cnk

#include <iostream.h>

#include <conio.h>

void giaithua(float n,float k)

{

float h,ngt,kgt,hgt,gt,gt1;

int i,j,m;

ngt=1;

kgt=1;

hgt=1;

h=n-k;

for (i=2;i<=n;i++)

{ngt*=i;}

for (j=2;j<=k;j++)

{kgt*=j;}

for (m=2;m<=h;m++)

{hgt*=m;}

gt1=(kgt*hgt);

gt=(ngt/gt1);

cout<<gt<<"

";

}

main()

{

float n,k;

cout<<"nhap vao gia tri n : ";cin>>n;

cout<<"nhap vao gia tri k : ";cin>>k;

cout<<"giai thua la :

";

giaithua(n,k);

getch();

}

Sp xêp day tng dân

#include <iostream.h>

#include <conio.h>

#include <ctype.h>

#include <iomanip.h>

#define in "nhap phan tu thu "

#define truoc "chuoi truoc khi sap xep la :

"

#define sau "chuoi sau khi sap xep la :

"

void nhap_mang(int *a,int n)

{

int i;

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

{

cout<<in<<i<<":";

cin>>*(a+i);

}

}

void sap_xep(int *a,int n)

{

int i,j,chuyen;

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

for (j=0;j<n;j++)

{

if (a[i]<a[j])

{

chuyen=a[i];

a[i]=a[j];

a[j]=chuyen;

}

}

}

void in_kq(int *a,int n)

{ int i;

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

{

cout<<setw(5)<<a[i];

}

}

main()

{

int mang[50],*a,n;

cout<<"moi ban nhap n : ";cin>>n;

a=&mang[0];

nhap_mang(a,n);

cout<<truoc;

in_kq(a,n);

cout<<"

";

sap_xep(a,n);

cout<<sau;

in_kq(a,n);

getch();

}

Ma trâ#n ¡n vi# Vuông (ham)

#include <iostream.h>

#include <conio.h>

#include <iomanip.h>

void ma_trandv(int a[][30],int n)

{

int i,j;

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

{

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

{

if (i=j) a[i][j]=1;

else

a[i][j]=0;

}

}

}

void in_kq(int a[][30],int n)

{

int i,j;

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

{

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

cout<<setw(5)<<a[i][j];

cout<<endl;

}

}

main()

{

int a[30][30],n;

cout<<"nhap vao cap cua ma tran vuong : ";cin>>n;

ma_trandv(a,n);

in_kq(a,n);

getch();

}

Nhâ#p mô#t xâu bât ky,chen mô#t ky t°# bât ky vao vi# tri bât ky trên xâu

#include <iostream.h>

#include <conio.h>

#include <string.h>

struct sinhvien

{

char ht[30];

float dtoan;

float dvan;

float dtin;

float tbc;

}sv;

void nhap_sv(char a[],float b,float c,float d,float e)

{

cout<<"nhap ten sv : ";

cin.getline(a,30);

cout<<"nhap diem toan : ";cin>>b;

cout<<"nhap diem van : ";cin>>c;

cout<<"nhap diem tin : ";cin>>d;

e=(b+c+d)/3;

cout<<"ho va ten : "<<a<<"

";

if(e<=4)

{

cout<<"ban phai thi lai

";

cout<<"diem tbc cua ban la : "<<e;

}

else cout<<"ban da qua mon va co diem tbc la :"<<e<<"

";

};

main()

{

nhap_sv(sv.ht,sv.dtoan,sv.dvan,sv.dtin,sv.tbc);

getch();

}

Sp xêp day gia m dân

#include <iostream.h>

#include <conio.h>

#include <ctype.h>

#include <iomanip.h>

#define in "nhap phan tu thu "

#define truoc "chuoi truoc khi sap xep la :

"

#define sau "chuoi sau khi sap xep la :

"

void nhap_mang(int *a,int n)

{

int i;

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

{

cout<<in<<i<<":";

cin>>*(a+i);

}

}

void sap_xep(int *a,int n)

{

int i,j,chuyen;

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

for (j=0;j<n;j++)

{

if (a[i]>a[j])

{

chuyen=a[i];

a[i]=a[j];

a[j]=chuyen;

}

}

}

void in_kq(int *a,int n)

{ int i;

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

{

cout<<setw(5)<<a[i];

}

}

main()

{

int mang[50],*a,n;

cout<<"moi ban nhap n : ";cin>>n;

a=&mang[0];

nhap_mang(a,n);

cout<<truoc;

in_kq(a,n);

cout<<"

";

sap_xep(a,n);

cout<<sau;

in_kq(a,n);

getch();

}

(Ham) cac phep tinh nhân,chia,cô#ng,tr°

#include <iostream.h>

#include <conio.h>

#include <ctype.h>

void tinh_nhan(int a,int b)

{

int tich=a*b;

cout<<"tich cua 2 so a va b la : "<<tich;

}

void tinh_chia(int a,int b)

{

int thuong=a/b;

cout<<"thuong cua 2 so a va b la : "<<thuong;

}

void tinh_tong(int a,int b)

{

int tong=a+b;

cout<<"tong cua 2 so a va b la : "<<tong;

}

void tinh_tru(int a,int b)

{

int hieu=a-b;

cout<<"hieu cua 2 so a va b la : "<<hieu;

}

main()

{

int a,b;

char hjc;

cout<<"

moi ban nhap vao 2 so a va b :

";

cout<<"moi ban nhap vao so a : ";cin>>a;

cout<<"moi ban nhap vao so b : ";cin>>b;

cout<<"

moi ban nhap vao phim theo huong dan

";

hi:cout<<"

bam phim 1 de chon phep nhan :

";

cout<<"bam phim 2 de chon chia :

";

cout<<"bam phim 3 de chon cong :

";

cout<<"bam phim 4 de chon tru :

";

cin>>hjc;

switch (hjc)

{

case '1' :cout<<"tinh_phep_nhan

\a";

tinh_nhan(a,b);break;

case '2' :cout<<"tinh_phep_chia

\a";

tinh_chia(a,b);break;

case '3' :cout<<"tinh_phep_cong

\a";

tinh_tong(a,b); break;

case '4' :cout<<"tinh_phep_tru

\a";

tinh_tru(a,b);break;

default :cout<<"ban da bam sai phim xin moi chon lai phim

";

hi;

}

getch();

}

Nôi hai xâu

#include <iostream.h>

#include <conio.h>

#include <string.h>

void nhap_xau(char xau1[100],char xau2[100])

{

cout<<"nhap vao xau 1 : ";cin.getline(xau1,100);

cout<<"nhap vao xau 2 : ";cin.getline(xau2,100);

}

void noi_2xau(char xau1[100],char xau2[100],char xau[100])

{

if (strcmp(xau1,xau2)>0){

xau=strcat(xau1,xau2);}

cout<<"xau sau khi da noi la : "<<xau;

}

main()

{

char xau1[100],xau2[100],xau[100];

nhap_xau(xau1,xau2);

noi_2xau(xau1,xau2,xau);

//in_xau(xau);

getch();

}

CÙng 2 ma tr­n

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

#include<math.h>

main ()

{

int A[10][10],B[10][10],C[10][10],i,j,n;

cout<<"nhap vao n=";cin>>n;

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

for(j=0;j<n;j++)

{

cout<<"A["<<i<<"]["<<j<<"]";

cin>>A[i][j];

cout<<"B["<<i<<"]["<<j<<"]";

cin>>B[i][j];

}

cout<<"Tong hai ma tran";

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

for(j=0;j<n;j++)

{

C[i][j]=A[i][j]+B[i][j];

}

cout<<"Ma tran Tong"<<endl;

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

{

for(j=0;j<n;j++)

cout<<setw(3)<<C[i][j];

cout<<endl;

}

getch ();

}

In hai ma trâ#n va cô#ng hai ma trâ#n o

#include <iostream.h>

#include <conio.h>

#include <iomanip.h>

void nhap_matran(int a[][20],int n)

{

int i,j;

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

for(j=0;j<n;++j)

{

cout<<"moi nhap vao hang thu :"<<i<<","<<j<<"

";

cin>>a[i][j];

}

}

void cong_matran(int a[][20],int b[][20],int c[][20],int n)

{

int i,j;

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

for(j=0;j<n;j++)

{

c[i][j]=a[i][j]+b[i][j];

}

}

void in_kq(int c[][20],int n)

{

int i,j;

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

{

for(j=0;j<n;j++)

cout<<setw(5)<<c[i][j];

cout<<endl;

}

}

main()

{int a[20][20],b[20][20],c[20][20];

int n;

cout<<"nhap vao cap cua ma tran : ";cin>>n;

cout<<"nhap vao ma tran a :

";

cout<<"

";

nhap_matran(a,n);

cout<<"nhap vao ma tran b :

";

cout<<"

";

nhap_matran(b,n);

cout<<"ma tran a la

";

in_kq(a,n);

cout<<"

";

cout<<"ma tran b la

";

in_kq(b,n);

cong_matran(a,b,c,n);

cout<<"

";

cout<<"ma tran sau khi tinh tong la :

";

in_kq(c,n);

getch();

}

Tich hai ma trâ#n(ham)

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

void nhap_ma_tran(int x[][10],int n)

{

int i,j;

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

{

cout<<"nhap hang thu : "<<i+1<<"

";

for (j=0;j<n;j++)

{

cout<<"a["<<i<<","<<j<<"]= ";

cin>>x[i][j];

}}

}

void nhan_ma_tran(int a[][10],int b[][10],int c[][10],int n)

{

int i,j,k;

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

for (j=0;j<n;j++)

{ c[i][j]=0;

for (k=0;k<n;k++)

c[i][j]=c[i][j]+a[i][k]*b[k][j];

}

}

void in_ma_tran(int c[][10],int n)

{

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

{

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

cout<<setw(3)<<c[i][j];

cout<<endl;

}

return;

}

main()

{

int a[10][10],b[10][10],c[10][10],n;

cout<<"nhap vao n : ";cin>>n;

cout<<"nhap ma tran a :

";

nhap_ma_tran(a,n);

cout<<"nhap ma tran b :

";

nhap_ma_tran(b,n);

nhan_ma_tran(a,b,c,n);

cout<<"in ket qua cua phep nhan :

";

in_ma_tran(c,n);

getch();

}

N sÑ tính TBC các sÑ d°¡ng,âm . so sánh TBC các sÑ d°¡ng và âm

#include <iostream.h>

#include <conio.h>

void main()

{

int n,ta,td, ssa,ssd;

float tba,tbd;

cout<<"nhap so cac so muon nhap: ";

cin>>n;

static int a[100];

int i;

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

cout<<"nhap so thu "<<i+1<<": ";

cin>>a[i] ;

}

ta=td=0;

ssa=ssd=0;

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

if(a[i]<0)

{

ta=ta+a[i];

ssa++ ;

}

else

{if(a[i]>0)

{

td=td+a[i];

ssd++;

}}

if(ssa!=0) {

tba=(float)ta/ssa ;

}

else {tba=0;}

if(ssd!=0)

{

tbd=(float)td/ssd;

}

else {

tbd=0;}

cout<<"day so vua nhap"<<"

";

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

cout<<a[i]<<" ";

cout<<"

";

cout<<"so am trong day: "<<ssa<<"

"<<"tong am: "<<ta<<"

"<<"trung binh cac so am: "<<tba<<"

";

cout<<"so duong trong day: "<<ssd<<"

"<<"tong duong: "<<td<<"

"<<"trung binh cac so duong: "<<tbd<<"

";

}

Vi¿t tr°¡ng trình tìm ki¿m sÑ tñ nhiên b¥t kó nh­p vào të bàn phím.¿m sÑ l§n và vË trí

#include <iostream.h>

#include <conio.h>

void main()

{

int n,sct,slxh;

cout<<"nhap so cac so muon nhap: ";

cin>>n;

static int a[100];

int i;

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

{

cout<<"nhap so thu "<<i+1<<": ";

cin>>a[i] ;

}

slxh=0;

cout<<"day so vua nhap"<<"

";

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

cout<<a[i]<<" ";

cout<<"

";

cout<<"nhap vao so can tim trong day: ";

cin>>sct;

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

if(a[i]==sct)

{

slxh++;

cout<<"

vi tri xuat hien "<<i+1;

}

cout<<"

so lan xuat hien: "<<slxh;

}

Nh­p vào n sÑ tñ nhiên tìm Min,Max,tÕng

#include<iostream.h>

#include<conio.h>

#include<iomanip.h>

main()

{

int i,n,m[100],min,max,tong;

cout<<"nhap vao so tu nhien n="; cin>>n;

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

{

cout<<"m["<<i<<"]="; cin>>m[i];

}

cout<<" cac phan tu vua nhap

";

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

{

cout<<setw(4)<<m[i]<<",";

}

min=m[0];

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

{

if(m[i]<min) min=m[i];

}

cout<<"

so min="<<min;

max=m[0];

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

{

if (m[i]>max) max=m[i];

}

cout<<"

so lon nhat la:"<<max;

tong=0;

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

{

tong=tong + m[i];

}

cout<<"

tong la:"<<tong;

getch();

}

Tính BMI

#include <iostream.h>

#include <stdlib.h>

#include <conio.h>

#define bmi1 "ban gay qua can tam bo the

%

&

¤

¥

, 0 1 6 > O U V

6€‚¼¾¹º,óèàØÌÀµØµ­¥­œÌ"̈­€tkbVKCK hÜOKCJaJ hÒLhÒLCJaJhÜOKh£'÷5CJaJh£'÷5CJaJhÜOK5CJaJhÜOKhÜOK5CJaJ hÒLCJaJ hU#¡hU#¡CJaJhU#¡5CJaJhhWC5CJaJ hEG1CJaJ hU#¡CJaJ hÓZ}hÓZ}CJaJhU#¡hÓZ}5CJaJhU#¡hU#¡5CJaJ hÓZ}CJaJ h\^ŒCJaJ hØxƒh\^ŒCJaJhÓZ}hÓZ}5CJaJ':Lrˆ'›Óûý & ( J L ^ ' y ' Ç à ù û

5

úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§â' µýý5

A

R

V

Y

[

b

d

y

Á

å

ö

úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§

&

<

O

a

Ÿ

ª

­

·

ï

#

8

G

K

m

q

...

¢

»

úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§»

ð

"

&

9

=

a

m

~

...

Ž

¥

É

í

! * , 1 2 3 4 5 6 7 8 úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§8 9 : ; < = > V l  " ¸ º Ä × ê í >@J]'s†‰‹­úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§­¯¹ÌÏâ

"&Jˆ®Ìî

úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§ "$&(*,.0246‚¾ê/68JY™µ¹ÓÚñûúúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§û,FGST[hy{¥¸×Ùö

" 6 A U ' t  úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§,.{|DNOPQ0¨ÐŒÊ#$‹Œ¢£ÕÖãäïùûþ

6DFøíäØÍÅͺø®£ø£ø£ø£›£ø£›£ø£Å£"‹‚ymdmh˜vŒ5CJaJh{d²h{d²5CJaJhhWC5CJaJh£'÷5CJaJ h{d²CJaJ hU#¡CJaJ hé'lCJaJ hÜOKhÜOKCJaJhÜOKhÜOK5CJaJ hðìhU#¡CJaJ h>2CJaJ hðìhðìCJaJhðìhðì5CJaJhðì5CJaJ hÒLhÒLCJaJ hÜOKCJaJ" ž ³ µ ¼ ¾ Ê ñ 4DNPQ0\‚¨ÒpÌ

#6Eúúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§EHJegx‹ž¢²µÆÕãæêì"%;>@GI]Œúúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§«¸ÇÖâïùûüýþÿ

Fr˜Â

DJrzúúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§F˜Àz~¦ª¶ºIJë줦©!ª!Æ!0"2"ª"Ò"6$7$Š$‹$¡$£$²$'$Ç$È$Ó$Ô$á$ã$²%³%î%ï%ø%ú%õíõíõíõíõíõåÝÑÅѺݲ¦š‡‡‡‡‡‡‡‡‡²vhhWC5CJaJ hfk CJaJ h>ÕCJaJ hp)

hp)

CJaJh>Õhp)

5CJaJh>Õh>Õ5CJaJ hp)

CJaJ h˜vŒh˜vŒCJaJh#_èh#_è5CJaJh#_èh˜vŒ5CJaJ h˜vŒCJaJ hU#¡CJaJ h{d²CJaJ h{d²h{d²CJaJ+z¦¶ÐÚàä04Ibptv}ÂÒÞçéêëìíîúúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§îïðñòóôõö÷øùúûüýþÿ¦Òø -@-úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§@-D-'-|---°-È-Ò- " : M o ± ¾ Ý æ è !'!)!c!f!m!o!Ÿ!¨!ª!«!úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§«!¬!­!®!¯!°!±!²!³!'!µ!¶!·!¸!¹!º!»!¼!½!¾!¿!À!Á!Â!Ã!Ä!Å!Æ!2"^"úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§^"„"ª"Ô"#r#Î#$$ $!$$$6$D$G$I$d$f$w$Š$$¡$²$¶$Ç$Ó$á$å$é$úúúúúúúúúúúñúúúúúúúúúúúúúúúú„Ð'„Ðgd-<§gd-<§é$ë$% %!%$%:%=%?%F%H%[%}%‰%™%¦%²%¿%Í%Ø%ä%í%ï%ð%ñ%ò%ó%ô%õ%ö%úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§ö%÷%ø%ù%ú%V&‚&¨&Î&'

'('|'€'¸'¼'à'( (<(>(N(x(z(•(-(§(Ñ(Ó(Ú(úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§ú%V&ˆ*‰*Ÿ+ +µ+¶+¼+,j,,Ü/Þ/ü/ö1÷1ø1F2˜2À2n4o4‰5Š5P7V7'7'7æ9ç9‡:‰:»:½:Ô:Ö:#;$;-;óèàèàèàØÌÁØÁصªŸà"ˆ€ˆ€ˆ€ˆàw"ˆ€ˆ€ˆ€ˆ€ˆlà h¨0>hfk CJaJhhWC5CJaJ h¨0>CJaJ h¨0>h¨0>CJaJh¨0>h¨0>5CJaJ h 'hfk CJaJ h 'h 'CJaJh 'h '5CJaJ hÚhÚCJaJhÚhÚ5CJaJ hÚCJaJ hfk CJaJ hfk hfk CJaJhfk hfk 5CJaJ'Ú(Ü(å(ï()F)o)¡)Ñ)÷)*B*M*[*^*ˆ*Ÿ*É*ß* +!+J+a+ +§+©+³+µ+¶+úúúúúúúúúúúúúúúúúñúñúñúúúúúú„Ð'„Ðgd-<§gd-<§¶+·+¸+¹+º+»+¼+,D,j,',ì,ð,R-'-¸-..2.h.š.ê.î.ü./F/r/¦/Æ/Ú/Þ/úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§Þ/ü/0%090J0R0T0}0™0ª0¼0½0À0Þ0í0

11171H1Z1^1y1}1™1ª1­1¿1úõõõõõõõõõõõõõõõõõõõõõõõõõõõgd 'gd-<§¿1Ù1æ1é1ê1õ1÷1ø1F2r2˜2Â2

3 3"3F3j3p3Ö3ô3ú3þ3;4=4G4Y4k4n4ˆ4úúúúúúõõõõõõõõõõõõõõõõõõõõõõgd-<§gd 'ˆ4‹44«4­4·4Ê4Í4ß4÷4555535=5i5Š5-5©5Ê5×5ê56 6:6n6ˆ6'6Ì6úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§Ì6"7:7L7P7R7T7V7X7Z7\7^7'7'7¼7à78)8+858H8K8p8ƒ8†8¤8²8¶8¸8õ8úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§õ8÷899,9<9P9r9v9x9›99'9·9Î9æ9ó9ø9::

:

:3:S:r:‡:¦:»:Ô:úúúúúúúúúúúúúúñúúúúúúúúúúúúú„Ð'„Ðgd-<§gd-<§Ô:ý:;;;-; ;!;";#;$;%;&;';(;);*;+;,;-;z<¦<Ì<ä<è<=6=€='=º=úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§-;z<„>...>'>'>¯>°>]?^?š@œ@°@ü@$A'A›C¶C¼CNDƒG„G'G'G›GÅG×GH"þšÿš½›Î›ý›óèàèàèàèàèØÐĻİبœ'†¨~rg¨geg]gUg hYÇCJaJ hÀI(CJaJU h-<§h-<§CJaJh-<§h-<§5CJaJ hp;'CJaJ hË4¾h-<§CJaJ hË4¾hË4¾CJaJhQc<hQc<5CJaJ h-<§CJaJ hý6¨hý6¨CJaJhý6¨5CJaJhý6¨hý6¨5CJaJ hý6¨CJaJ hfk CJaJ h7ECJaJ h7Eh7ECJaJh7Eh7E5CJaJ!º=Ê=ô=>*>->7>C>U>a>d>q>z>}>„>'>">¤>¯>³>Â>Ø>Ü>ì>ù>ý>??-?)?úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§)?J?]?o?{?ß?˜@œ@ž@ @¢@¤@¦@¨@ª@¬@®@°@'AŒA²AÊAÎAðAB&B:BBBVBúúúñúúúúúúúúúúúúúúúúúúúúúúúú„Ð'„Ðgd-<§gd-<§VBYB{B‰BŒB•B¶BÉBÜBêB C-C1C@CCCLCpCsC™C›CœCCžCŸC C¡C¢C£C¤C¥Cúúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§¥C¦C§C¨C©CªC«C¬C­C®C¯C°C±C²C³C'CµC¶C·C¸C¹CºC»C¼CNDxDœDÄDÒDúúúúúúúúúúúúúúúúúúúúúúúõõõõõgdË4¾gd-<§ÒDÖD EjE'EšEÞEæEF*F.FJFNFZFmFqFŠFŽFFF«F·F¸FÌFÑFìFñFG G5GúúúúúúúúúúúúúúúúúúúúúúúúúúúúúgdË4¾5G:GOGTGrGsGG„G...G†G‡GˆG‰GŠG‹GŒGGŽGGG'G'G›G±GÅGØG"%"["úúúúúúúõõõõõõõõõõõõõõõõõõõõõgd-<§gdË4¾m"

#define bmi2 "ban kha can doi do"

#define bmi3 "ban hoi beo va can an uong dieu do hon"

#define bmi4 "ban da bi beo phi va can chua tri kip thoi"

#define bmi5 "ban da bi beo phi"

void tinhtoan(float w,float h);

void incach1(float w,float h);

void namcach2(float w,float h,char gioitinh);

void nucach2(float w,float h,char gioitinh);

void incach2(float w,float h,char gioitinh);

void tinhcach2(float w,float h,char gioitinh);

main()

{

float w,h,bmi;

char hi,gioitinh,hjc;

lai:

clrscr();

cout<<"moi ban bam phim theo huong dan

";

cout<<"_______________________________

";

cout<<"

";

cout<<"bam 1 de chon cach tinh BMI 1 :

";

cout<<"bam 2 de chon cach tinh BMI 2 :

";

cout<<"bam 3 de quay lai ban dau :

";

cout<<"bam 4 de thoat khoi chuong trinh :

";

cin>>hi;

switch (hi)

{

case '1' :cout<<"ban da chon cach 1 :

";

cout<<"nhap vao can nang : ";cin>>w;

cout<<"nhap vao chieu cao : ";cin>>h;

tinhtoan(w,h);

incach1(w,h);

cout<<"

";

cout<<"bam phim t de quay lai chuong trinh

";cin>>hjc;

if (hjc='t') goto lai;

break;

case '2' :cout<<"ban da chon cach 2 :

";

cout<<"nhap vao can nang : ";cin>>w;

cout<<"nhap vao chieu cao : ";cin>>h;

cout<<"nhap vao gioi tinh (f hoac m) : ";cin>>gioitinh;

incach2(w,h,gioitinh);

cout<<"

";

cout<<"bam phim t de quay lai chuong trinh

";cin>>hjc;

if (hjc=='t') goto lai;

break;

case '3' :goto lai;

break;

case '4' :exit(0);

break;

}}

void tinhtoan(float w,float h)

{

float bmi;

bmi=w/(h*h);

cout<<"bmi cua ban la : "<<bmi<<"

";

}

void incach1(float w,float h)

{

float bmi;

if (bmi<18.5)

cout<<bmi1<<"

";

if (bmi>=18.5&&bmi<=24.9)

cout<<bmi2<<"

";

if (bmi>=25&&bmi<=29.9)

cout<<bmi3<<"

";

if (bmi>=30&&bmi<=34.9)

cout<<bmi5<<"

";

if (bmi>=35)

cout<<bmi4<<"

";

}

void namcach2(float w,float h,char gioitinh)

{ float bmi;

bmi=w/(h*h);

cout<<"ban la :"<<gioitinh<<"emale

";

if (bmi<18)

cout<<bmi1<<"

";

if (bmi>=18&&bmi<=23)

cout<<bmi2<<"

";

if (bmi>=23&&bmi<=30)

cout<<bmi3<<"

";

if (bmi>30)

cout<<bmi4<<"

";}

void nucach2(float w,float h,char gioitinh)

{ float bmi;

bmi=w/(h*h);

cout<<"ban la : "<<gioitinh<<"ale

";

if (bmi<19)

cout<<bmi1<<"

";

if (bmi>=20&&bmi<=25)

cout<<bmi2<<"

";

if (bmi>=25&&bmi<=30)

cout<<bmi3<<"

";

if (bmi>30)

cout<<bmi4<<"

"; }

void incach2(float w,float h,char gioitinh)

{float bmi;

switch (gioitinh)

{ case 'f' : tinhcach2(w,h,gioitinh);

namcach2(w,h,gioitinh);

break;

case 'm' : tinhcach2(w,h,gioitinh);

nucach2(w,h,gioitinh);

break;} }

void tinhcach2(float w,float h,char gioitinh)

{ float bmi;

bmi=w/(h*h);

cout<<"bmi cua ban la : "<<bmi<<"

";

}

Nh­p 2 xâu,in 2 xâu và ghép 2 xâu

#include <conio.h>

#include <ctype.h>

#include <iostream.h>

#include <string.h>

main()

{

int dem1=0,dem2=0;

char xau1[30],xau2[30],c;

cout<<"nhap xau 1:";cin>>xau1;

cout<<"nhap xau 2:";

cin.ignore(80,'

');

cin.get(xau2,30);

cout<<"Xau 1: "<<xau1<<endl;

cout<<"Xau 2: "<<xau2<<endl;

while(xau1[dem1]!='\0')

dem1++;

cout<<"so ky tu xau 1:"<<dem1<<"

";

while(xau2[dem2]!='\0')

dem2++;

cout<<"so ky tu xau 2:"<<dem2<<"

";

if((sizeof(xau1)-strlen(xau1))>=strlen(xau2))

strcat(xau1,xau2);

cout<<xau1;

getch();

}

TÕng cça n sÑ nh­p vào të bàn phím

#include <iostream.h>

#include <conio.h>

void nhap_mang(int *p,int n)

{

int i;

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

{

cout<<i<<":";cin>>*(p+i);

}

}

void tinh_tong(int *p,int n)

{

int i,tong;

tong=0;

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

{

tong=tong+*p;["•"¶"Ö"õ"#•P•}•¬•³•µ•Å•Ü•â•í•-C-O-{-§-Ï-ÿ- ---C-h-Ž--«-úúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§«-Ä-ý- ˜˜E˜k˜'˜É˜à˜ì˜%™=™D™X™_™s™{™™ž™ ™¬™º™à™â™ššúúúúúíúúúúúúúúúúúúúúúäúúúú

Ƽ gd*Hã

„Ôþ„˜þ]„Ôþ^„˜þgd-<§gd-<§š šš/šIš[šsš...šš¯š¼šÎšÐšýš

››A›M›_›u›‡›Ÿ›±›½›Ð›ü› œœ>œJœúúúúúúúúúúúúúúúúúúúúúúúúúúúúúgd-<§ý›þ›¹œÊœÌœúœûœ¥¦×Øø0ž2ž4žvžxž;¡<¡D¢¤'Ð'Ñ'á'â'ã'å'æ'è'é'ë'ì'î'ï'õ'ö'÷'øíåøíåíøíøíøíåíÚη¯£˜-˜‹¯€xtxtxtxtjdjd

hp;'0Jjhp;'0JUhõ'jhõ'U hfk hfk CJaJ h}éhfk CJaJU h}éh}éCJaJh}éh}é5CJaJ hfk CJaJ hpChpCCJaJhpChfk 5CJaJhpChpC5CJaJ h-<§hfk CJaJ hYÇCJaJ h-<§h-<§CJaJ hÀI(CJaJ'Jœ]œsœ...œ›œ­œ¹œÎœúœ@X_...œ¨Öãñ0ž4žxžžžÄžðžŸ&Ÿ*ŸúúúúúúúúúúúúúúúúúúúúúúõõõõõõgdpCgd-<§*ŸPŸ„ŸÂŸìŸ

: W o w œ ' ¼ á ¡$¡1¡:¡<¡D¢p¢-¢Ð¢Ô¢ä¢

££D£úúúúúúúúúúúúúúúúúúúúõõõõõõõõgd}égdpCD£J£N£ˆ£Œ£¦£¸£Þ£ä£''7'9'@'B'V'{'£'''Å'Ï'Ñ'Ò'Ó'Ô'Õ'Ö'×'Ø'úúúúúúúúúúúúúúúúúúúúúõõõõõõõgd-<§gd}ép++;

}

cout<<"tong cua "<<i<<" so la : "<<tong<<endl;

}

main()

{

int mang[30],*p,n;

cout<<"moi nhap vao so n : ";cin>>n;

cout<<"gia tri cua pt thu ";p=&mang[0];

nhap_mang(p,n);

tinh_tong(p,n);

getch();

}

PAGE

PAGE 6

Bạn đang đọc truyện trên: Truyen247.Pro

Tags: #qeddf