drawing sign
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | #include <stdio.h> #include <math.h> #define MAXIMUM 1000 #define PI 3.14159265359 struct Trigonometric_Function { float sign[MAXIMUM]; float cosign[MAXIMUM]; float tangent[MAXIMUM]; }; int Function_Sign (struct Trigonometric_Function* _trigonometric, int Angle); int Drawing_Sign (struct Trigonometric_Function* _trigonometric, char space[][MAXIMUM], int the_number_of_sign); void Space_Print (char space[][MAXIMUM], int limit_horizon); void Drawing_Graticule (char space[][MAXIMUM]); void print (struct Trigonometric_Function* _trigonometric); // int main (void) { struct Trigonometric_Function trigonometric = { .sign = { 0, }, .cosign = { 0, }, .tangent = { 0, } }; char Space[40 + 1][MAXIMUM] = { (char) 0, }; int radian = 360; int the_number_of_sign = Function_Sign (&trigonometric, radian); Drawing_Graticule (Space); Drawing_Sign (&trigonometric, Space, the_number_of_sign); Space_Print (Space, 51); //print (&trigonometric); // testing return 0; } int Drawing_Sign (struct Trigonometric_Function* _trigonometric, char space[][MAXIMUM], int the_number_of_sign) { int index = 0; for (index = 0; index < the_number_of_sign; index++) { _trigonometric->sign[index] *= 20; space[(40 / 2) - (int)_trigonometric->sign[index]][index] = 's'; } return 0; } int Function_Sign (struct Trigonometric_Function* _trigonometric, int Angle) { int The_Number_Of_Sign = 0; int loop = 0, index = 0, unit = 10; for (loop = 0, index = 0; loop < Angle + 1; loop += unit, index++) { _trigonometric->sign[index] = sin(PI * loop / 180.f); The_Number_Of_Sign++; } return The_Number_Of_Sign; } void Space_Print (char space[][MAXIMUM], int limit_horizon) { int row = 0, column = 0; for (column = 0; column < 40 + 1; column++) { for (row = 0; row < limit_horizon; row++) { printf ("%2c", space[column][row]); } printf ("\n"); } } void Drawing_Graticule (char space[][MAXIMUM]) { int loop = 0; for (loop = 0; loop < 40 + 1; loop++) { space[loop][0] = '['; } for (loop = 0; loop < MAXIMUM; loop++) { space[(40 + 1 - 1) / 2][loop] = '-'; } return; } void print (struct Trigonometric_Function* _trigonometric) { // testing int loop = 0; for (loop = 0; loop < 19; loop++) { printf ("%f\n", _trigonometric->sign[loop]); } } | cs |
0 개의 댓글:
댓글 쓰기