Archived
Работы по программированию
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
int main() {
|
||||
FILE *initialFile = fopen("input.txt", "w");
|
||||
if (initialFile == NULL) {
|
||||
printf("Не удалось создать файл input.txt\n");
|
||||
return 1;
|
||||
}
|
||||
fprintf(initialFile, "3 5 4 5 9\n");
|
||||
fclose(initialFile);
|
||||
|
||||
FILE *inputFile = fopen("input.txt", "r");
|
||||
if (inputFile == NULL) {
|
||||
printf("Не удалось открыть файл input.txt\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE *outputFile = fopen("output.txt", "w");
|
||||
if (outputFile == NULL) {
|
||||
printf("Не удалось открыть файл output.txt\n");
|
||||
fclose(inputFile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
float a, b, c, d, e;
|
||||
|
||||
fscanf(inputFile, "%f %f %f %f %f", &a, &b, &c, &d, &e);
|
||||
|
||||
fclose(inputFile);
|
||||
|
||||
float numerator = pow(a, 3) * pow(b, 5);
|
||||
numerator = pow(numerator, c);
|
||||
float denominator = pow(d, 5) * pow(e, 9);
|
||||
float result = numerator / denominator;
|
||||
|
||||
fprintf(outputFile, "%.2f\n", result);
|
||||
|
||||
fclose(outputFile);
|
||||
|
||||
printf("Вычисления завершены, результат записан в output.txt\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user