-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcedure.cpp
More file actions
44 lines (38 loc) · 1.32 KB
/
Procedure.cpp
File metadata and controls
44 lines (38 loc) · 1.32 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
//------------------------------------------------------------------------------
// Procedure.cpp - implementation of Procedure.h.
//------------------------------------------------------------------------------
#include "Procedure.h"
//------------------------------------------------------------------------------
// Input parameters from file.
void In(Procedure &c, FILE *file) {
fscanf(file, "%100s", &c.name);
fscanf(file, "%i", &c.year);
fscanf(file, "%lf", &c.popularity);
fscanf(file, "%i", &c.abstract_type);
}
// Random parameters.
void InRnd(Procedure &c) {
c.abstract_type = bRandom();
c.popularity = dRandom();
c.year = yRandom();
int k = 0;
for(char i = 'a'; i < 'z'; i++){
c.name[k] = i;
k++;
}
}
//------------------------------------------------------------------------------
// Output
void Out(Procedure &c, FILE *file) {
if (c.abstract_type){
}
fprintf(file, "It is Procedure language: Have abstract type %i\n", c.abstract_type);
fprintf(file, ". Popularity = %lf\n", c.popularity);
fprintf(file, ". Year = %i\n", c.year);
fprintf(file, ". Parameter = %lf", Average(c));
}
//------------------------------------------------------------------------------
// Get average
double Average(Procedure &c) {
return (c.year * 1.0 / strlen(c.name));
}