Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- //#include "Answer.h"
- #include <string>
- using namespace std;
- struct Answer
- {
- int sum;
- float mean;
- int count;
- string text;
- };
- Answer Decide(int* ar, int n, string com);
- //////////////////////////////////////////////////////////////////////
- int main()
- {
- setlocale(LC_ALL, "RUS");
- int A[] = { 2, 6, 7 };
- Answer otvet = Decide(A, 3, "массив А");
- cout << otvet.sum << endl;
- cout << otvet.mean << endl;
- cout << otvet.count << endl;
- cout << otvet.text << endl;
- }
- //////////////////////////////////////////////////////////////////////
- Answer Decide(int* ar, int n, string com)
- {
- Answer ans;
- ans.sum = 0;
- ans.count = 0;
- ans.mean = 0;
- ans.text = com;
- for(int i = 0; i < n; i++)
- {
- if (ar[i] > 0)
- {
- ans.count++;
- ans.sum += ar[i];
- }
- }
- ans.mean = ans.sum/n;
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment