1. Trang chủ
  2. » Giáo Dục - Đào Tạo

CẤU TRÚC VÀ CÁC HÀM THAO TÁC TRÊN SỐ PHỨC

4 664 5

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

CẤU TRÚC VÀ CÁC HÀM THAO TÁC TRÊN SỐ PHỨC include typedef struct tagcomplex { float thuc, ao; } complex; complex tong(complex a, complex { complex c; c.thuc = a.thuc + b.thuc; c.ao = a.ao + b.ao; return c; } complex hieu(complex a, complex { complex c; c.thuc = a.thuc b.thuc; c.ao = a.ao b.ao; return c; } complex tich(complex a, complex { complex c; c.thuc = a.thucb.thuc a.aob.ao; c.ao = a.thucb.ao + a.aob.thuc; return c; } complex thuong(complex a, complex { complex c; float tongbp; tongbp = b.thucb.thuc + b.aob.ao; c.thuc = (a.thuca.ao + b.thucb.ao)tongbp; c.ao = (a.aob.thuc a.thucb.ao)tongbp; return c; } float argument(complex a) { return acos(a.thucsqrt(a.thuca.thuc + a.aoa.ao)); } float modul(complex a) { return sqrt(a.thuca.thuc + a.aoa.ao); }

CẤU TRÚC VÀ CÁC HÀM THAO TÁC TRÊN SỐ PHỨC #include <math.h> typedef struct tagcomplex { float thuc, ao; } complex; complex tong(complex a, complex { complex c; c.thuc = a.thuc + b.thuc; c.ao = a.ao + b.ao; return c; } complex hieu(complex a, complex { complex c; c.thuc = a.thuc - b.thuc; c.ao = a.ao - b.ao; return c; } complex tich(complex a, complex { complex c; c.thuc = a.thuc*b.thuc - a.ao*b.ao; c.ao = a.thuc*b.ao + a.ao*b.thuc; return c; } complex thuong(complex a, complex { complex c; float tongbp; tongbp = b.thuc*b.thuc + b.ao*b.ao; c.thuc = (a.thuc*a.ao + b.thuc*b.ao)/tongbp; c.ao = (a.ao*b.thuc - a.thuc*b.ao)/tongbp; return c; } float argument(complex a) { return acos(a.thuc/sqrt(a.thuc*a.thuc + a.ao*a.ao)); } float modul(complex a) { return sqrt(a.thuc*a.thuc + a.ao*a.ao); } void print_complex(complex a) { printf("%.2f + %.2fi", a.thuc, a.ao); } void main() { complex a, b, c; printf("\nNhap he so thuc va phuc cua A : "); scanf("%f%f", &a.thuc, &a.ao); printf("\nNhap he so thuc va phuc cua B : "); scanf("%f%f", &b.thuc, &b.ao); printf("\nSo phuc A = "); print_complex(a); printf("\nSo phuc B = "); print_complex( ; printf("\nTong cua chung = "); c = tong(a, ; print_complex©; printf("\nHieu cua chung = "); c = hieu(a, ; print_complex©; printf("\nTich cua chung = "); c = tich(a, ; print_complex©; printf("\nThuong cua chung = "); c = thuong(a, ; print_complex©; printf("\nArgument cua a = %f", argument(a)); printf("\nModul cua a = %f", modul(a)); getch(); } . CẤU TRÚC VÀ CÁC HÀM THAO TÁC TRÊN SỐ PHỨC #include <math.h> typedef struct tagcomplex { float thuc, ao; } complex; complex

Ngày đăng: 12/11/2014, 21:40

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w