Move some functions to util
This commit is contained in:
parent
59053ba109
commit
c25a0a5045
20
main.c
20
main.c
@ -10,10 +10,6 @@
|
||||
|
||||
void find_end(int, char *, char *, int **, int *);
|
||||
|
||||
void apply_shift(int, int *, int);
|
||||
|
||||
int sum_array(int *, int);
|
||||
|
||||
void initialize();
|
||||
|
||||
void distribute_text();
|
||||
@ -229,19 +225,3 @@ void collect_results(int *match_number, int *matches) {
|
||||
MPI_COMM_WORLD
|
||||
);
|
||||
}
|
||||
|
||||
void apply_shift(int shift, int *array, int size) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
array[i] += shift;
|
||||
}
|
||||
}
|
||||
|
||||
int sum_array(int *array, int size) {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < size; ++i) {
|
||||
sum += array[i];
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
14
util.c
14
util.c
@ -15,6 +15,20 @@ void print_array(int *array, int length) {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void apply_shift(int shift, int *array, int size) {
|
||||
for (int i = 0; i < size; ++i) {
|
||||
array[i] += shift;
|
||||
}
|
||||
}
|
||||
|
||||
int sum_array(int *array, int size) {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < size; ++i) {
|
||||
sum += array[i];
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
char *read_file(char *filepath, int *len) {
|
||||
FILE *f = fopen(filepath, "r");
|
||||
|
Loading…
Reference in New Issue
Block a user