New Main

  • Upload
    cobra

  • View
    4

  • Download
    0

Embed Size (px)

DESCRIPTION

hh

Citation preview

#include #include #include #include #define LUC printf("%c",201); // left upper corner#define HDL printf("%c",205); // horizontal double line#define RUC printf("%c",187); // right upper corner#define VDL printf("%c",186); // vertical double line#define LLC printf("%c",200); // left low corner#define RLC printf("%c",188); // right low corner#define MUC printf("%c",209); // middle upper cross#define VSL printf("%c",179); // vertical single line#define MCC printf("%c",197); // middle center cross#define MLC printf("%c",199); // middle left cross#define MRC printf("%c",182); // middle right cross#define HSL printf("%c",196); // horizontal single line#define MCL printf("%c",207); // middle cross lowtypedef struct { double real; double img; } complex;complex Z1, Z2, q, p;const double pi = 3.14159265358979323846264; // the constant PIint i; // the counter of your choisedouble r1, r2; //the modulus under the root.char sign1, sign2, i1, i2; //sign of the num +i or -i.voidshow_cmplx() { if (sign1 == '-' && sign2 == '-') { LUC for (i = 0; i = 0) h = 180 - h; if (Z2.real < 0 && p.img < 0) h = 180 + h; if (Z2.real >= 0 && p.img < 0) h = 360 - h; printf("\n\tThe angle of the first number Z1 = %0.0f grades.", g); printf("\n\tThe angle of the second number Z2 = %0.0f grades.", h); printf("\n\n"); return 0; }intmodulus_cmplx() { check_sign(); r1 = ((Z1.real * Z1.real) + (q.img * q.img)); r2 = ((Z2.real * Z2.real) + (p.img * p.img)); printf("\n\tThe modulus of the first number Z1 = %c%0.0lf = %0.3lf\n", 251, r1, sqrt(r1)); printf("\n\tThe modulus of the second number Z2 = %c%0.0lf = %0.3lf\n", 251, r2, sqrt(r2)); printf("\n\n"); return 0; }intconvert_to_tri_cmplx() { float g, h, o, n; check_sign(); r1 = ((Z1.real * Z1.real) + (q.img * q.img)); r2 = ((Z2.real * Z2.real) + (p.img * p.img)); // for first number g = atan(q.img / Z1.real); g = (g * 180) / pi; if (g < 0) g *= -1; if (Z1.real > 0 && q.img > 0) g = g; if (Z1.real < 0 && q.img >= 0) g = 180 - g; if (Z1.real < 0 && q.img < 0) g = 180 + g; if (Z1.real >= 0 && q.img < 0) g = 360 - g; // for second number h = atan(p.img / Z2.real); h = (h * 180) / pi; if (h < 0) h *= -1; if (Z2.real > 0 && p.img > 0) h = h; if (Z2.real < 0 && p.img >= 0) h = 180 - h; if (Z2.real < 0 && p.img < 0) h = 180 + h; if (Z2.real >= 0 && p.img < 0) h = 360 - h; o = (sqrt(r1))*(cos(g) + sin(g)); n = (sqrt(r2))*(cos(h) + sin(h)); printf("\n\tThe first number Z1 = %c%0.0lf(COS(%0.0lf)+iSIN(%0.0lf)) = %0.2lfi\n", 251, r1, g, g, o); printf("\n\tThe second number Z2 = %c%0.0lf(COS(%0.0lf)+iSIN(%0.0lf)) = %0.2lfi\n", 251, r2, h, h, n); printf("\n\n"); return 0; }intconvert_to_exp() { float g, h; check_sign(); r1 = ((Z1.real * Z1.real) + (q.img * q.img)); r2 = ((Z2.real * Z2.real) + (p.img * p.img)); // for first number g = atan(q.img / Z1.real); g = (g * 180) / pi; if (g < 0) g *= -1; if (Z1.real > 0 && q.img > 0) g = g; if (Z1.real < 0 && q.img >= 0) g = 180 - g; if (Z1.real < 0 && q.img < 0) g = 180 + g; if (Z1.real >= 0 && q.img < 0) g = 360 - g; // for second number h = atan(p.img / Z2.real); h = (h * 180) / pi; if (h < 0) h *= -1; if (Z2.real > 0 && p.img > 0) h = h; if (Z2.real < 0 && p.img >= 0) h = 180 - h; if (Z2.real < 0 && p.img < 0) h = 180 + h; if (Z2.real >= 0 && p.img < 0) h = 360 - h; printf("\n\tThe first number Z1 = %c%0.0lfexp^(i%0.0lf)\n", 251, r1, g); printf("\n\tThe first number Z2 = %c%0.0lfexp^(i%0.0lf)\n", 251, r2, h); printf("\n\n"); return 0; }intmain() { int running = 1; int com1; int i; int input_flag = 0; complex c; setlocale(LC_ALL, "1252"); system("color 9e"); while (1) { while (running) { running = 0; system("cls"); show_menu(); printf("\nCommand