#include <iostream> #include <ctime> #include <stdlib.h> using namespace std;
double Sum(int *A, int N, int C, int M);
int main() { srand(time(0)); int N, C = 19, M = 30; cout << "N = ", cin >> N; int Train[N]; for(int i = 0; i < N; i++) cout << (Train[i] = rand() % (M+1)) << " "; cout << "\nSum = " << Sum(&Train[0], N, C, M);; return 0; }
double Sum(int*A, int N, int C, int M) { double S = 0; int k = 0; for(int i = 0; i < N; i++) { S += A[i]*C; k +=M - A[i]; } cout << "\nk = " << k; return S; }
#include <iostream> #include <ctime> #include <stdlib.h> using namespace std;
double Sum(int *A, int N, int C, int M);
int main() { srand(time(0)); int N, C = 19, M = 30; cout << "N = ", cin >> N; int Train[N]; for(int i = 0; i < N; i++) cout << (Train[i] = rand() % (M+1)) << " "; cout << "\nSum = " << Sum(&Train[0], N, C, M);; return 0; }
double Sum(int*A, int N, int C, int M) { double S = 0; int k = 0; for(int i = 0; i < N; i++) { S += A[i]*C; k +=M - A[i]; } cout << "\nk = " << k; return S; }
#include <ctime>
#include <stdlib.h>
using namespace std;
double Sum(int *A, int N, int C, int M);
int main()
{
srand(time(0));
int N, C = 19, M = 30;
cout << "N = ", cin >> N;
int Train[N];
for(int i = 0; i < N; i++)
cout << (Train[i] = rand() % (M+1)) << " ";
cout << "\nSum = " << Sum(&Train[0], N, C, M);;
return 0;
}
double Sum(int*A, int N, int C, int M)
{
double S = 0;
int k = 0;
for(int i = 0; i < N; i++)
{
S += A[i]*C;
k +=M - A[i];
}
cout << "\nk = " << k;
return S;
}
#include <ctime>
#include <stdlib.h>
using namespace std;
double Sum(int *A, int N, int C, int M);
int main()
{
srand(time(0));
int N, C = 19, M = 30;
cout << "N = ", cin >> N;
int Train[N];
for(int i = 0; i < N; i++)
cout << (Train[i] = rand() % (M+1)) << " ";
cout << "\nSum = " << Sum(&Train[0], N, C, M);;
return 0;
}
double Sum(int*A, int N, int C, int M)
{
double S = 0;
int k = 0;
for(int i = 0; i < N; i++)
{
S += A[i]*C;
k +=M - A[i];
}
cout << "\nk = " << k;
return S;
}