News Ticker

Menu

HKI Thực Hành Lần 9 - Bài 9.2


/*
Ten: Hoang Minh Tuan
Lop: GS19TH1
*/
#include<stdio.h>
#include<conio.h>
#define max 100
typedef struct HinhVuong{
float canh, chuvi, dientich;
};

void nhap(HinhVuong &b);
void nhapmang(HinhVuong a[], int &n);
float chuv(HinhVuong &b);
float dient(HinhVuong &b);
void xuat(HinhVuong b);
void xuatmang(HinhVuong a[], int &n);
void tongcv(HinhVuong a[], int &n);
void tbcong(HinhVuong a[], int &n);


int main(){
HinhVuong a[max], b; int n;

printf("=============================== NHAP DANH SACH HV ======================\n"); nhapmang(a,n);
printf("=============================== XUAT DANH SACH HV ======================\n"); xuatmang(a,n);
printf("=============================== TONG CHU VI HV ======================\n"); tongcv(a,n);
printf("\n========================== TB DIEN TICH VI HV ==================\n"); tbcong(a,n);
printf("\n\n\n ========================== END ==================\n");
printf(" By Hoang Minh Tuan \n");
getch();
return 0;
}

void nhap(HinhVuong &b){
printf("Nhap Canh= "); scanf("%f", &b.canh);
}

void nhapmang(HinhVuong a[], int &n){
printf("So Luong Hinh Vuong Can Nhap: "); scanf("%i", &n);
for(int i=0;i<n;i++){
printf("Hinh Vuong Thu [%i]\n", i+1);
nhap(a[i]);
printf("\n");
}
}

float chuv(HinhVuong &b){
b.chuvi= (b.canh * 4);
return b.chuvi;
}

float dient(HinhVuong &b){
b.dientich= b.canh * 2;
return b.dientich;
}

void xuat(HinhVuong b){
printf("Canh= %.2f", b.canh);
}

void xuatmang(HinhVuong a[], int &n){
for(int i=0;i<n;i++){
printf("Hinh Vuong Thu [%i]\n", i+1);
xuat(a[i]);
chuv(a[i]);
printf("\nChu Vi= %.2f", chuv(a[i]));
dient(a[i]);
printf("\nDien Tich= %.2f", dient(a[i]));
printf("\n\n");
}
}

void tongcv(HinhVuong a[], int &n){
float t= 0;
for(int i=0;i<n;i++){
t+= a[i].chuvi;
}
printf("Tong Chu Vi= %.2f", t);
}

void tbcong(HinhVuong a[], int &n){
float tbc= 0;
for(int i=0;i<n;i++){
tbc+= a[i].dientich;
}
float ttb;
ttb= tbc/n;
printf("TB Cong Dien Tich HV= %.2f", ttb);
}

Share This:

Post Tags:

Welcome To Task Marks

I'm Task Marks. Tôi là chủ trang web này, trang này tôi dùng để chia sẽ tài liệu và những thứ linh tinh khác. Cảm ơn mọi người đã ghé thăm trang web của chúng tôi.Nếu có thắt mắt xin vui lòng liên hệ
Mail: devnguhoc@gmail.com

No Comment to " HKI Thực Hành Lần 9 - Bài 9.2 "

  • To add an Emoticons Show Icons
  • To add code Use [pre]code here[/pre]
  • To add an Image Use [img]IMAGE-URL-HERE[/img]
  • To add Youtube video just paste a video link like http://www.youtube.com/watch?v=0x_gnfpL3RM