-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprog2_3.sh
More file actions
executable file
·79 lines (71 loc) · 1.88 KB
/
prog2_3.sh
File metadata and controls
executable file
·79 lines (71 loc) · 1.88 KB
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
#!/bin/bash
echo "Assignment #2-3, Antoine Rakotozafy, antoine.rakotozafy@gmail.com"
echo ""
#Add a line in each C files : #include <stdlib.c> to avoid the warning message when we compile them
sed -i '2i#include <stdlib.h>' *.c
#Compiler les fichiers c
gcc $1 -o prog1 -lm
gcc $2 -o prog2 -lm
gcc $3 -o prog3 -lm
gcc $4 -o prog4 -lm
#Execute each program with a known value
prog1Test=$(echo `./prog1 9`)
prog2Test=$(echo `./prog2 9`)
prog3Test=$(echo `./prog3 9`)
prog4Test=$(echo `./prog4 9`)
#Assignement 1 (result 0.988)
if [ "$prog1Test" == "0.988" ]
then
echo $1 "Assignment #1"
elif [ "$prog2Test" == "0.988" ]
then
echo $2 "Assignment #1"
elif [ "$prog3Test" == "0.988" ]
then
echo $3 "Assignement #1"
elif [ "$prog4Test" == "0.988" ]
then
echo $4 "Assignement #1"
fi
#Assignement 2 (result 3.0000)
if [ "$prog1Test" == "3.0000" ]
then
echo $1 "Assignment #2"
elif [ "$prog2Test" == "3.0000" ]
then
echo $2 "Assignment #2"
elif [ "$prog3Test" == "3.0000" ]
then
echo $3 "Assignement #2"
elif [ "$prog4Test" == "3.0000" ]
then
echo $4 "Assignement #2"
fi
#Assignement 3 (result : 0.90000 )
if [ "$prog1Test" == "0.90000" ]
then
echo $1 "Assignment #3"
elif [ "$prog2Test" == "0.90000" ]
then
echo $2 "Assignment #3"
elif [ "$prog3Test" == "0.90000" ]
then
echo $3 "Assignement #3"
elif [ "$prog4Test" == "0.90000" ]
then
echo $4 "Assignement #3"
fi
#Assignement 4 (not the same as 1,2 and 3)
if [[ "$prog1Test" != "0.988" && "$prog1Test" != "3.0000" && "$prog1Test" != "0.90000" ]]
then
echo $1 "Assignement #4"
elif [[ "$prog2Test" != "0.988" && "$prog2Test" != "3.0000" && "$prog2Test" != "0.90000" ]]
then
echo $2 "Assignement #4"
elif [[ "$prog3Test" != "0.988" && "$prog3Test" != "3.0000" && "$prog3Test" != "0.90000" ]]
then
echo $3 "Assignement #4"
elif [[ "$prog4Test" != "0.988" && "$prog4Test" != "3.0000" && "$prog4Test" != "0.90000" ]]
then
echo $4 "Assignement #4"
fi