Một số ví dụ
Trang 1 trong tổng số 1 trang
Một số ví dụ
- Code:
// TruuTuongHoaDuLieu.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include "conio.h"
#include "stdio.h"
// Khai báo kiểu phân số
struct PhanSo
{
int tuso;
int mauso;
};
typedef struct PhanSo PHANSO;
// Khai báo kiểu điểm trong toán học
struct Diem
{
float x;
float y;
};
typedef struct Diem DIEM;
//Khai báo hỗn số trong toán học
struct HonSo
{
int nguyen;
int tu;
int mau;
};
typedef struct honso HONSO;
//Khai báo điểm trong không gian
struct DiemKhongGian
{
float x;
float y;
float z;
};
typedef struct DiemKhongGian DIEMKHONGGIAN;
//Khai báo kiểu thời gian
struct ThoiGian
{
int gio;
int phut;
int giay;
};
typedef struct THOIGIAN;
//Khai báo kiểu thời gian
struct Ngay
{
int ng;
int th;
int nm;
};
typedef struct NGAY;
//Các hàm được định nghĩa trong Struct phân số
void NhapPhanSo(PHANSO &x)
{
printf("\nNhap tu so: ");
scanf("%d", &x.tuso);
printf("\nNhap mau so: ");
scanf("%d", &x.mauso);
}
void XuatPhanSo(PHANSO &x)
{
printf(" %d / %d",x.tuso, x.mauso);
}
void NhapDiem(DIEM &x)
{
printf("\nNhap hoang do ");
scanf("%d",&x.x);
printf("\nNhap tung do ");
scanf("%d",&x.y);
}
void Xuat(DIEM x)
{
printf("\n [%d,%d] ",x.x,x.y);
}
void main()
{
printf("Ket thuc...");
getch();
}
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|