Dấu sao tam giác vuông
#include"stdio.h"
#include"conio.h"
#include"math.h"
void main()
{
clrscr();
int n,i,j,k;
printf ("\nBan hay nhap so nguyen duong n
sao cho 0<n<25");
printf ("\nn=");scanf ("%d",&n);
for (i=1;i<=n;i++)
{
for (j=1;j<=i;j++)
printf ("*");
printf ("\n");
}
getch();
}
đọc số bằng chữ
#include"conio.h"
#include"stdio.h"
#include"math.h"
void main()
{
clrscr();
int a,b,c,n,k;
k=0;
do
{
printf ("\nBan hay nhap so n sao cho
0<n<1000");
printf ("\nn=");scanf ("%d",&n);
if (n<1000) k=1;
if (k==0) printf ("\nBan hay nhap lai n");
}
while (k==0);
a=n%10;
n=n/10;
b=n%10;
n=n/10;
c=n%10;
printf ("\nSo ban vua nhap vao la: ");
switch(c)
{
case 0:printf (" ");break;
case 1:printf ("mot ");break;
case 2:printf ("hai ");break;
case 3:printf ("ba "); break;
case 4:printf ("bon ");break;
case 5:printf ("nam ");break;
case 6:printf ("sau ");break;
case 7:printf ("bay ");break;
case 8:printf ("tam ");break;
case 9:printf ("chin ");break;
default:break;
}
if (c!=0) printf ("tram ");
if ((c!=0)&&(b==0)) printf ("linh ");
if (b!=0)
{
switch(b)
{
case 1:printf ("muoi ");break;
case 2:printf ("hai ");break;
case 3:printf ("ba "); break;
case 4:printf ("bon ");break;
case 5:printf ("nam ");break;
case 6:printf ("sau ");break;
case 7:printf ("bay ");break;
case 8:printf ("tam ");break;
case 9:printf ("chin ");break;
default:break;
}
}
if (b>1) printf ("muoi ");
else printf (" ");
switch(a)
{
case 0:printf (" ");break;
case 2:printf ("hai ");break;
case 3:printf ("ba "); break;
case 4:printf ("bon ");break;
case 5:printf ("nam ");break;
case 6:printf ("sau ");break;
case 7:printf ("bay ");break;
case 8:printf ("tam ");break;
case 9:printf ("chin ");break;
}
getch();
}
ucln,bcnn
#include"conio.h"
#include"stdio.h"
#include"math.h"
void main()
{
clrscr();
int a,b,c,i,USCLN,BSCNN;
printf ("\nBan hay nhap 2 so nguyen duong a
va b");
printf ("\na=");scanf ("%d",&a);
printf ("\nb=");scanf ("%d",&b);
for (i=1;i<=a;i++)
{
1
if ((a%i==0)&&(b%i==0)) USCLN=i;
}
printf ("\nUoc so chung lon nhat la
%d",USCLN);
BSCNN=(a*b)/USCLN;
printf ("\nBoi so chung nho nhat la
%d",BSCNN);
getch();
}
sao hình tam giác
#include"stdio.h"
#include"conio.h"
#include"math.h"
void main()
{
clrscr();
int n,i,j,k;
printf ("\nBan hay nhap so nguyen duong n
sao cho 0<n<25");
printf ("\nn=");scanf ("%d",&n);
for (i=1;i<=n;i++)
{
for (j=1;j<=n-i;j++)
printf (" ");
for (j=1;j<=2*i-1;j++)
printf ("*");
printf ("\n");
}
getch();
}
dấu sao tam giác vuông_bài 8
#include"stdio.h"
#include"conio.h"
#include"math.h"
void main()
{
clrscr();
int n,i,j,k;
printf ("\nBan hay nhap so nguyen duong n
sao cho 0<n<25");
printf ("\nn=");scanf ("%d",&n);
for (i=1;i<=n;i++)
{
for (j=1;j<=n-i;j++)
printf (" ");
for (j=1;j<=i;j++)
printf ("*");
printf ("\n");
}
getch();
}
in ra chữ số lẻ
#include"stdio.h"
#include"conio.h"
#include"math.h"
void main()
{
clrscr();
int m,n,d,t;
printf ("\nBan hay nhap vao so nguyen duong
n");
printf ("\nn=");scanf ("%d",&n);
m=n;
t=0;
while (m!=0)
{
d=m%10;
m=m/10;
if (d%2==1)
{
printf ("\nCac chu so le cua %d la %d ",n,d);
t=1;
}
}
if (t==0) printf ("\n%d khong co chu so le
nao",n);
getch();
}
viết 00 đến 99
#include"conio.h"
#include"stdio.h"
#include"math.h"
void main()
{
clrscr();
int i,j;
for (i=0;i<=9;i++)
{
for (j=0;j<=9;j++)
printf ("%7d",i*10+j);
printf ("\n");
}
getch();
}
nhập số nguyên dương không quá 4 số
#include"stdio.h"
#include"conio.h"
2
#include"math.h"
void main()/*Luu y n la kieu nguyen nen khi
nhap n khong qua 32767*/
{
clrscr();
int k,n,m,d,t;
k=0;
t=0;
do
{
printf ("\nBan hay nhap n la so co khong qua 4
chu so");
printf ("\nn=");scanf ("%d",&n);
if (n<10000) k=1;
if (k==0) printf ("\nBan hay nhap lai n");
}
while (k==0);
m=n;
while (d!=0)
{
d=m%10;
m=m/10;
t=t+d;
}
printf ("\nTong cac chu so cua %d la %d",n,t);
getch();
}
in ra tam giác số
#include"stdio.h"
#include"conio.h"
#include"math.h"
void main()
{
clrscr();
int n,i,j,k;
printf ("\nBan hay nhap so nguyen duong n
sao cho 0<n<25");
printf ("\nn=");scanf ("%d",&n);
for (i=1;i<=n;i++)
{
for (j=1;j<=n-i;j++)
printf (" ");
for (j=1;j<=i;j++)
printf ("%d",j);
for (j=1;j<=i-1;j++) printf ("%d",i-j);
printf ("\n");
}
getch();
}
các số xuất hiện hơn 1 lần 1 dãy
#include"conio.h"
#include"stdio.h"
#include"math.h"
void main()
{
clrscr();
int a[50],n,i,j,tg,k;
printf ("\nBan hay nhap n");
printf ("\nn=");scanf ("%d",&n);
printf ("\nNhap cac phan tu trong day:");
for (i=1;i<=n;i++)
{
printf ("\nPhan tu thu %d la ",i);scanf
("%d",&a[i]);
}
for (i=1;i<n;i++)
for (j=i+1;j<=n;j++)
if (a[i]>a[j])
{
tg=a[i];
a[i]=a[j];
a[j]=tg;
}
k=0;
printf ("\nCac so xuat hien nhieu hon 1 lan
trong day la: ");
for (i=1;i<n;i++)
if (a[i]==a[i+1])
{
printf ("%d ",a[i]);
for (j=i+1;j<=n;j++)
if (a[i]!=a[j])
{
i=j-1;
break;
}
}
getch();
}
diện tích tam giác
#include"math.h"
#include"conio.h"
#include"stdio.h"
void main() /*Tinh dien tich tam giac*/
{
clrscr();
float a,b,c,p,dientich;
printf ("Ban hay nhap chieu dai 3 canh cua tam
giac a,b,c");
printf ("\na=");scanf ("%f",&a);
printf ("\nb=");scanf ("%f",&b);
printf ("\nc=");scanf ("%f",&c);
3
if ((a+b>c)&&(b+c>a)&&(c+a>b))
{
p=(a+b+c)/2;
dientich=sqrt(p*(p-a)*(p-b)*(p-c));
printf ("\nDien tich tam giac la %f",dientich);
}
else printf ("\na,b,c khong phai 3 canh cua 1
tam giac");
getch();
}
pt bậc 2
#include"math.h"
#include"conio.h"
#include"stdio.h"
void main() /*Giai phuong trinh bac 2*/
{
clrscr();
float a,b,c,denta;
printf ("Ban hay nhap 3 so a,b,c");
printf ("\na=");scanf ("%f",&a);
printf ("\nb=");scanf ("%f",&b);
printf ("\nc=");scanf ("%f",&c);
denta=b*b-4*a*c;
if (denta<0) printf ("\nPhuong trinh vo
nghiem");
else if (denta==0) printf ("\nPhuong trinh co
nghiem kep x1=x2=%f",-b/2*a);
else printf ("\nPhuong trinh co 2 nghiem
\nx1=%f \nx2=%f",(-b-sqrt(denta))/2*a,(-
b+sqrt(denta))/2*a);
getch();
}
pt bậc 4
#include"stdio.h"
#include"math.h"
#include"conio.h"
void main() /*Giai phuong trinh bac 4*/
{
clrscr();
float a,b,c,denta;
printf ("\nBan hay nhap 3 so a,b,c");
printf ("\na=");scanf ("%f",&a);
printf ("\nb=");scanf ("%f",&b);
printf ("\nc=");scanf ("%f",&c);
denta=b*b-4*a*c;
if (denta<0) printf ("\nPhuong trinh vo
nghiem");
else if (denta==0) printf ("\nPhuong trinh co 2
nghiem \nx1=%f \nx2=%f",(-sqrt(-b/2*a)),
(sqrt(-b/2*a)));
else printf ("\nPhuong trinh co 4 nghiem
phan biet \nx1=%f \nx2=%f \nx3=%f \nx4=
%f",(-sqrt((-b+sqrt(denta))/2*a)),(sqrt((-
b+sqrt(denta))/2*a)),(-sqrt((-b-
sqrt(denta))/2*a)),(sqrt((-b-sqrt(denta))/2*a)));
getch();
}
tìm số lớn nhất trong 3 số
#include"math.h"
#include"conio.h"
#include"stdio.h"
void main() /*Tim so lon nhat trong 3 so*/
{
clrscr();
float a,b,c,max;
printf ("Ban hay nhap 3 so a,b,c");
printf ("\na=");scanf ("%f",&a);
printf ("\nb=");scanf ("%f",&b);
printf ("\nc=");scanf ("%f",&c);
if (a>b) max=a;
else max=b;
if (max<c) max=c;
printf ("\nSo lon nhat trong 3 so la %f",max);
getch();
}
bảng cửu chương
#include"conio.h"
#include"stdio.h"
#include"math.h"
void main()
{
clrscr();
int i,j;
for (i=1;i<=10;i++)
{
for (j=1;j<=10;j++)
printf ("%7d",i*j);
printf ("\n");
}
getch();
}
F=x/1!+x2/2!+…+xn/n!
#include"stdio.h"
#include"conio.h"
#include"math.h"
4
void main()
{
clrscr();
float x,f;
int n,sh,a,i;
printf ("Ban hay nhap n va x");
printf ("\nx=");scanf ("%f",&x);
printf ("\nn=");scanf ("%d",&n);
sh=1;
f=0;
a=1;
for (i=1;i<=n;i++)
{
sh=sh*x;
a=a*i;
f=f+(float)(sh)/a;
}
printf ("\nGia tri cua bieu thuc la f=%f",f);
getch();
}
mức tăng dân số hàng năm
#include"conio.h"
#include"stdio.h"
#include"math.h"
void main()
{
clrscr();
int x,z,t;
float y;
printf ("\nBan hay nhap x,y,z");
printf ("\nDan so the gioi hien tai la ");scanf
("%d",&x);
printf ("\nMuc tang dan so hang nam la
");scanf ("%f",&y);
printf ("\nDan so the gioi trong tuong lai
");scanf ("%d",&z);
t=0;
while (x<z)
{
x=x+x*(float)(y)/100;
t++;
}
printf ("\nSo nam de dan so vuot qua %d
nguoi la %d ",z,t);
getch();
}
in ra n ở dạng nhị phân
#include"stdio.h"
#include"conio.h"
#include"math.h"
void main()
{
clrscr();
int m,n,d,t,k;
printf ("\nBan hay nhap vao so nguyen duong
n");
printf ("\nn=");scanf ("%d",&n);
m=n;
t=0;
k=0;
while (m!=0)
{
d=m%2;
m=m/2;
t=t+d*pow(10,k);
k++;
}
printf ("\nDang nhi phan cua %d la %d",n,t);
getch();
}
in ra n ở hệ đếm cơ số 16
#include"stdio.h"
#include"conio.h"
#include"math.h"
void main()
{
clrscr();
int a[50],d,m,n,i,j;
printf ("Ban hay nhap n");
printf ("\nn=");scanf ("%d",&n);
m=n;
i=0;
while (m!=0)
{
d=m%16;
m=m/16;
i=i+1;
a[i]=d;
}
printf ("\n%d bieu dien duoi dang co so 16
la:",n);
for (j=i;j>=1;j )
switch (a[j])
{
case 10:printf ("A");break;
case 11:printf ("B");break;
case 12:printf ("C");break;
case 13:printf ("D");break;
case 14:printf ("E");break;
case 15:printf ("F");break;
default:printf ("%d",a[j]);
}
getch();
}
5
in ra màn hình những số nguyên tố < n
#include"conio.h"
#include"math.h"
#include"stdio.h"
void main()
{
clrscr();
int n,i,j,kt;
printf ("\nBan hay nhap n");
printf ("\nn=");scanf ("%d",&n);
for (i=1;i<n;i++)
{
kt=1;
for (j=2;j<=i-1;j++)
if (i%j==0)
{
kt=0;
break;
}
if (kt==1) printf ("\nSo nguyen to nho hon n la
%d",i);
}
getch();
}
in ra những số hoàn hảo < n
#include"conio.h"
#include"math.h"
#include"stdio.h"
void main()
{
clrscr();
int n,i,j,t;
printf ("\nBan hay nhap n");
printf ("\nn=");scanf ("%d",&n);
for (i=1;i<n;i++)
{
t=0;
for (j=1;j<=i;j++)
if (i%j==0) t=t+j;
if (t/i==2) printf ("\nSo hoan hao nho hon n la
%d",i);
}
getch();
}
in ra màn hình giá trị biểu thức f(x,y)
#include"conio.h"
#include"math.h"
#include"stdio.h"
void main()
{
clrscr();
float x,y,f;
printf ("\nBan hay nhap x,y");
printf ("\nx=");scanf ("%f",&x);
printf ("\ny=");scanf ("%f",&y);
if (x<y) f=2*x-y*y+2;
if (x==y) f=exp(x*y-y)+sin(x-3*y);
if (x>y) f=log(x*x*x-2*x*y)
+sqrt(x*x+2*y*y);
printf ("\nGia tri bieu thuc la %f",f);
getch();
}
S=1
k
+ 2
k
+….+3
k
#include"conio.h"
#include"stdio.h"
#include"math.h"
void main()
{
clrscr();
int n,k,i,s;
printf ("\nBan hay nhap 2 so n va k");
printf ("\nn=");scanf ("%d",&n);
printf ("\nk=");scanf ("%d",&k);
s=0;
for (i=1;i<=n;i++) s=s+pow(i,k);
printf ("\nGia tri cua tong voi n=%d va x=%d
la %d",n,k,s);
getch();
}
f(a,b)=3a
2
b -|a-b| +e
2a+1
#include"conio.h"
#include"math.h"
#include"stdio.h"
void main()
{
clrscr();
float x,f,a,b;
printf ("\nBan hay nhap x");
printf ("\nx=");scanf ("%f",&x);
if (x<1) a=abs(x*x-3*x+2)+sin(2*x-1);
else if (1<=x<=2) a=sqrt(x*x-1)-log(x-
1)/log(3);
else a=exp(2*x+3)-pow(x,5)+3;
b=pow(x,5)-3*x*x+2;
f=3*a*a*b-abs(a-b)+exp(2*a+1);
printf ("\nGia tri bieu thuc la: %f",f);
getch();
}
6
!
1
)1 (
!3
1
!2
1
!1
1
1
n
s
n +
−++−=
#include<stdio.h>
#include<conio.h>
#include<math.h>
float s=0;int n,i,gt=1;
void main()
{clrscr();
printf("\nnhap n=");scanf("%d",&n);
for(i=1;i<=n;i++)
{gt=gt*i;
s=s+pow(-1,i+1)*(1/float(gt));
}
printf("\ntong co gia tri la:%4.1f",s);
getch();
}
nhập a,b,c thỏa mãn độ dài 3 cạnh tam giác
#include"stdio.h"
#include"conio.h"
#include"math.h"
void main()
{
clrscr();
float a,b,c;
int k;
k=0;
do
{
printf ("\nBan hay nhap a,b,c la do dai 3 canh
1 tam giac");
printf ("\na=");scanf ("%f",&a);
printf ("\nb=");scanf ("%f",&b);
printf ("\nc=");scanf ("%f",&c);
if
((a>0)&&(b>0)&&(c>0)&&(a+b>c)&&(b+c>
a)&&(c+a>b)) k=1;
if (k==0) printf ("\Ban hay nhap lai a,b,c");
}
while (k==0);
printf ("\nDo dai 3 canh cua tam giac ban vua
nhap la \na=%f\nb=%f\nc=%f",a,b,c);
getch();
}
chu vi, diện tích, đường cao tam giác
#include"stdio.h"
#include"conio.h"
#include"math.h"
void main()
{
clrscr();
float a,b,c,p,s;
int k;
k=0;
do
{
printf ("\nBan hay nhap a,b,c la do dai 3 canh
1 tam giac");
printf ("\na=");scanf ("%f",&a);
printf ("\nb=");scanf ("%f",&b);
printf ("\nc=");scanf ("%f",&c);
if
(a>0)&&(b>0)&&(c>0)&&(a+b>c)&&(b+c>a
)&&(c+a>b)) k=1;
if (k==0) printf ("\Ban hay nhap lai a,b,c");
}
while (k==0);
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
printf ("\nChu vi cua tam giac la %f",2*p);
printf ("\nDien tich cua tam giac la %f",s);
printf ("\nDo dai cua 1 duong cao la
%f",2*s/a);
getch();
}
mảng 1 chiều
#include"conio.h"
#include"stdio.h"
#include"math.h"
void nhap(int a[50],int *n)
{
int i;
printf ("\nBan hay nhap n");
printf ("\nn=");scanf ("%d",n);
printf ("\nNhap cac phan tu trong day A:\n");
for (i=1;i<=*n;i++)
{
printf ("\nNhap phan tu thu %d= ",i);
scanf ("%d",&a[i]);
}
}
void hienthi(int a[50],int n)
{
int i;
printf ("\nDay A ban vua nhap la: ");
for (i=1;i<=n;i++) printf ("%d ",a[i]);
printf ("\n");
}
void soam(int a[50],int n)
{
int i,k,t;
k=0;
for (i=1;i<=n;i++)
7
if (a[i]<0)
{
k=1;
t=i;
break;
}
if (k==0) printf ("\nDay A vua nhap khong co
so am");
else printf ("\nVi tri so am dau tien trong day
A tu trai sang phai la %d",t);
}
void slt2(int a[50],int n)
{
int i,j,tg;
for (i=1;i<n;i++)
for (j=i+1;j<=n;j++)
{
if (a[i]>a[j])
{
tg=a[i];
a[i]=a[j];
a[j]=tg;
}
}
printf ("\nSo lon thu nhi trong day A la
%d",a[n-1]);
}
void xapxep(int a[50],int n)
{
int i,j,tg;
for (i=1;i<n;i++)
for (j=i+1;j<=n;j++)
{
if ((a[i]%2==0)&&(a[j]%2!=0))
{
tg=a[i];
a[i]=a[j];
a[j]=tg;
}
}
printf ("\nDay A da xap xep la: ");
for (i=1;i<=n;i++) printf ("%d ",a[i]);
}
void kt(int a[50],int n)
{
int i,j,k;
k=0;
for (i=1;i<n;i++)
for (j=i+1;j<=n;j++)
{
if (a[i]*a[j]<0) k=1;
else k=0;
}
if (k==1) printf ("\nDay A la day dan dau");
else printf ("\nDay A khong phai day dan
dau");
}
void tbc(int a[50],int n)
{
int i,t;
float tbc;
t=0;
for (i=1;i<=n;i++)
t=t+a[i];
tbc=(float)(t)/n;
printf ("\nTrung binh cong cac so trong day A
la %f",tbc);
}
void so(int a[50],int n)
{
int i,j,k;
k=0;
printf ("\nCac so trong day xuat hien nhieu
hon mot lan la: ");
for (i=1;i<n;i++)
{
for (j=i+1;j<=n;j++)
if (a[i]==a[j])
{
a[j]=a[j+1];
n=n-1;
k=1;
}
if (k==1) printf ("%d ",a[i]);
}
}
void snt(int a[50],int n)
{
int i,j,tg,k;
for (i=1;i<n;i++)
for (j=i+1;j<=n;j++)
{
if (a[i]>a[j])
{
tg=a[i];
a[i]=a[j];
a[j]=tg;
}
if (a[i]>a[j])
{
for (k=j;k<n;k++)
a[k]=a[k+1];
n=n-1;
i=i-1;
}
}
void main()
{
int a[50],n,k;
8
nhap(a,&n);
hienthi(a,n);
soam(a,n);
slt2(a,n);
xapxep(a,n);
kt(a,n);
tbc(a,n);
so(a,n);
snt(a,n);
getch();
}
mảng 2 chiều
#include<stdio.h>
#include<conio.h>
/*nhap mang hai chieu*/
void nhap(int A[10][10],int*n)
{int i,j,tg;
printf("nhap kich thuoc ma tran
n=");scanf("%d",n );
for (i=1;i<=*n;i++)
for (j=1;j<=*n;j++)
{
printf("nhap cac phan tu hang %d cot
%d=",i,j);
scanf("%d",&tg);
A[i][j]=tg;
}
}
/*hien thi A ra man hinh*/
void hienthi(int A[10][10],int n)
{
int i,j;
printf ("ma tran vua nhap:");
for (i=1;i<=n;i++)
{
for (j=1;j<=n;j++)
printf ("%3d",A[i][j]);
printf("\n");
}
}
/*tim phan tu nho nhat tren
ma tran*/
void sonhonhat(int A[10][10],int n)
{
int min,i,j;
min=A[1][1] ;
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
if (A[i][j]<min)min=A[i][j];
}
/*hien thi cac phan tu hang chan*/
void hienthihangchan(int A[10][10],int n)
{
int i,j;
printf ("cac phan tu tren cac hang co chi so
chan \n:");
for (i=1;i<=n;i++)
{
if (i%2==0)
{
printf("\n cac phan tu tren hang %d",i);
for (j=1;j<=n;j++)
printf ("%3d",A[i][j]);
printf("\n");
}
}}
/*xap xep cac ham theo
thu tu tang dan*/
void xapxephang(int A[10][10],int n)
{
int i,j,k,tg;
printf ("nhap hang k=");
scanf ("%d",k);
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
if (A[k][i]<A[k][j])
{
A[k][i]=A[k][j];
A[k][j]=tg;
}
printf ("ma tran sau khi xap xep hang %d",k);
for (i=1;i<=n;i++)
{ for (j=1;j<=n;j++)
printf ("%3d",A[i][j]);
printf("\n");
}}
/*voi k mot so bat ky nhap tu ban
phim in ra so lan xuat
hien cua k trong ma tran*/
void solanxuathien(int A[10][10],int n)
{
int k ,d,i,j;
printf ("nhap k=");
scanf("%d",&k);
d=0;
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
if (A[i][j]==k)d++;
printf("so lan xuat hien cua %d trong ma tran
la %d,k,d");
}
/*tim phan tu nho nhat tren duong
cheo chinh ma tran*/
void phantunhonhat(int A[10][10],int n)
{
int min,i,j;
min= A[1][1];
9
for (i=2;i<=n;i++)
if (A[i][j]<min ) min =A[i][j];
printf ("so nho nhat la %2d",min);
}
/*tinh va in ra trung binh cong cac
phan tu
tren duong cheo ma tran*/
void tcc(int A[10][10],int n)
{
int i,t=0;
for (i=1;i<=n;i++)
t=t+A[i][i];
printf ("trung binh cong cac phan tu tren
duong cheo chinh=%35.1f",(float)n);
}
/*tich hai ma tran*/
void tich(int A[10][10],int B[10][10],int n)
{
int C[10][10],i,j,k;
for (i=1;i<=n;i++)
for (j=1;j<=n;j++)
{
C[i][j]=0;
for (k=1;k<=n;k++)C[i][j]=A[i][j]*B[i][j];
printf ("tich hai ma tran la %f",C[i][j]);
}
}
/*in ra man hinh cac phan tu trong
vung duoc danh dau
cua ma tran A*/
void in( int A[10][10],int n)
{
int i,j;
for (i=1;i<=n;i++)
{ for (j=1;j<=n;j++)
printf ("%3d",A[i][j]);
printf ("\n");
}
}
/*so sanh cac phan tu am va phan
tu duong trong ma tran*/
void sosanh(int A[10][10],int n)
{
int dd,da,i,j;
for(i=1;i<=n;i++)
for (j=1;j<=n;j++)
if (A[i][j]<0)da++;
else if (A[i][j]>0)dd++;
if (da>dd)printf ("so luong phan tu am lon
hon");
else printf("so luong phan tu am nho hon hoac
bang so luong phan tu duong");
}
/*in ra man hinh hang co tong lon
nhat*/
void inhangmax(int A[10][10],int n)
{
int max,h,i,j,t;
t=0;
for (i=1;i<=n;i++)
t=t+A[1][i];max=t,h=1;
for (i=2;i<=n;i++)
{t=0;
for (j=1;j<=n;j++)
t=t+A[i][j];
if (t>max){max=t;h=i;}
for (i=1;i<=n;i++)
printf("%2d",A[h][i]);
}
}
void main()
{
clrscr();
int A[10][10],n;
nhap(A,&n);
hienthi(A,n);
hienthihangchan(A,n);
xapxephang(A,n);
getch();
}
ma trận vuông
#include<stdio.h>
#include<conio.h>
int a[15][15];
int i,j;
void main()
{clrscr();
for(j=0;j<=9;j++)
{a[0][j]=j;printf("%3d",a[0][j]);}
printf("\n");
i=1;
while(i<=9)
{for(j=0;j<=9;j++)
{a[i][j]=a[i-1][j]+10;
printf("%3d",a[i][j]);
}
printf("\n");
i++;
}
getch();
}
10
. canh cua tam giac ban vua
nhap la
a=%f
b=%f
c=%f",a,b ,c) ;
getch();
}
chu vi, diện tích, đường cao tam gi c
#include"stdio.h"
#include"conio.h"
#include"math.h"
void. /*hien thi cac phan tu hang chan*/
void hienthihangchan(int A[10][10],int n)
{
int i,j;
printf ("cac phan tu tren cac hang co chi so
chan
:");
for