Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication10.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
- //
- #include "pch.h"
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- float f(float* mas, int n) {
- FILE *pf;
- float sum=0;
- char name[80];
- gets(name);
- cout << name << endl;
- pf = fopen(name, "r");
- for (int i = 0; i < n; i++) {
- fscanf(pf, "%f\n", mas + i);
- sum += mas[i];
- }
- fclose(pf);
- return sum;
- }
- int main()
- {
- const int n = 10;
- float m[n], c;
- float sum = f(&m[0], n);
- cout << sum << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement