forked from PBYetml/EMSY_TP1_Source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEMSY_TP1.c
149 lines (121 loc) · 3.38 KB
/
EMSY_TP1.c
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//-----------------------------------------------------------------------------------//
// Nom du projet : EMSY TP1
// Nom du fichier : EMSY_TP1.c
// Date de création : 11.11.24
// Date de modification : -
//
// Auteur : Henri Mott
//
// Version : 0.1
//
// Description : code qui peut calculer la surface géométrique de plusieurs objets
//
//
// Remarques : Peut-être lourdement amélioré
//----------------------------------------------------------------------------------//
//--- librairie standart ---//
#include <stdio.h> // pour usage printf et scanf_s
// Nouveauté du VC++ 2005, 2008, 2010 et 2015 : le scanf_s remplace scanf
//-- apple de librairies
#include <math.h> //
#include <corecrt_math_defines.h>
//-- programme principale --//
void main()
{
while (1)
{
//-- déclaration de variable --//
//type nom_variable
//type entier
int shape, Hight_m, lenght_m, radius_m, pi_m = 3.14;
//For the surface aria
float surfacetriangle_m2, surfaceCarre_m2, circle_m2;
enum e_choixSurface { Triangle, square = 1, circle }; // 0 1 2 get incremented by it's self
//surfacetriangle_m2 = powf(longueur_m,2);
// intruction 1
// Formats what we get to a single chatacter
int scanf(const char* format);
//First question
printf("Make a choise: Triangle(0), Square(1), or circle(2):\n ");
//Wait for shape to come
scanf("%d", &shape);
//Feed-back on what shape chosen
switch (shape)
{
case 0:
printf("shape chosen = Triangle\n");
break;
case 1:
printf("shape chosen = Square\n");
break;
case 2:
printf("shape chosen = circle\n");
break;
default:
break;
}
//-------------------------------------
// triangle
if (shape == 0)
{
//Second question
printf("Hight ?\n ");
//Wait for dimentions
scanf("%d", &Hight_m);
//Feed-back on what longeur chosen
printf("Hight = %d\n", Hight_m);
//-------------------------------------
//Second question
printf("lenght ?\n ");
//Wait for dimentions
scanf("%d", &lenght_m);
//Feed-back on what largeur chosen
printf("lenght = %d\n", lenght_m);
//Result
surfacetriangle_m2 = (lenght_m * Hight_m / 2);
printf("surfacetriangle %f\n", surfacetriangle_m2);
printf("Done :DD\n");
//-------------------------------------
}
// square
if (shape == 1)
{
//-------------------------------------
//Second question
printf("Hight ?\n ");
//Wait for dimentions
scanf("%d", &Hight_m);
//Feed-back on what longeur chosen
printf("Hight = %d\n", Hight_m);
//-------------------------------------
//Second question
printf("largeur ?\n ");
//Wait for dimentions
scanf("%d", &lenght_m);
//Feed-back on what largeur chosen
printf("longeur = %d\n", lenght_m);
//Result
surfaceCarre_m2 = (lenght_m * Hight_m);
printf("surfaceCarre %f\n", surfaceCarre_m2);
printf("Done :P\n");
//-------------------------------------
}
// circle
if (shape == 2)
{
//Second question
printf("radius ?\n ");
//Wait for dimentions
scanf("%d", &radius_m);
//Feed-back on what radius chosen
printf("radius %d\n", radius_m);
//Result
// circle_m2 = MI_PI * (radius_m * radius_m);
// circle_m2 = MI_PI* powf (radius_m,2);
circle_m2 = (radius_m * pi_m);
printf("circle %f\n", circle_m2);
printf("Done :0\n");
//-------------------------------------
}
}
}