Getting to the solution of tasks, read articles Arrays in C++ and The random number generator rand(), if you have not read them. Try to address the proposed tasks independently and watch our decisions only in extremis.
1. Create an array of type int on 10 elements and fill it with random numbers from 7 to 14. After filling overwrite all numbers, who for more than ten: from the stored value to take away 10. For example the number is stored in the cell 12: 12 – 10 = 2. Write to this cell 2 Writing the new value, use composite(combined) statements.
2. To fill an array of elements 50 odd numbers from 1 to 99. (use the operation remainder of the division, to check on the number of parity)
3. Declare three arrays. The first two to fill with random values from 10 to 30. In the third elements of the array to record the amount of the corresponding elements of the first two sets. (in the third cell zero – the sum of zero cells first and second arrays, and so on). Then, find the arithmetic mean of the elements of the third array, the maximum value and minimum value, which it holds.
given an array of 15 whole numbers. Calculate the amount from the minimum among odd numbers ending in 3 or 5 to the last element of the array
crayon-623bf4019bac8489391054/ 11 crayon-623bf4019bac8489391054/
int main()
{
int arr[10];
std::crayon-623bf4019bac8489391054/; //crayon-623bf4019bac8489391054/, crayon-623bf4019bac8489391054/
std::crayon-623bf4019bac8489391054/(random()); //crayon-623bf4019bac8489391054/
std::crayon-623bf4019bac8489391054/(7, 14); //range integer generator
for (int i = 0; i < 10; i )
{
arr[i] range integer generator(range integer generator);
}
for (int i = 0; i 10) arr[i] -= 10;
std::cout << arr[i] << " ";
}
return 0;
}
range integer generator
Ratings for 10 athletes, participating in athletics competitions, exhibited 3 judges. The scores of each judge are written in an array. Determine the scores of each of the athletes.
#include
#include
#include
using namespace std;
int main(){
int arr[10];
srand(time(NULL));
for(int i=0;i<10;i ){
arr[i]=7+rand()%8;
}
for(int i=0;i<10;i )
cout << arr[i]<<'\t';
cout << endl;
for(int i=0;i=10)
arr[i] -= 10;
}
for(int i=0;i<10;i )
cout << arr[i]<< '\t';
return 0;
}
#include
#include
#include
using namespace std;
int main(){
const int SIZE = 10;
int i = 0;
srand(time(NULL));
int firstArray[SIZE];
int secondArray[SIZE];
for(int j = 0;j<SIZE;j ){
firstArray[j]=10 + rand() % 21;
cout << firstArray[j] <<'\t';}
cout << endl;
for(int i = 0;i<SIZE;i ){
secondArray[i]=10 + rand() % 21;
cout << secondArray[i] <<'\t';}
cout << endl;
int thirdArray[] = {};
for(int k = 0;k < SIZE;k ){
thirdArray[k]=firstArray[k]+secondArray[k];
cout << thirdArray[k] << '\t';}
cout << endl;
//The arithmetic average thirdArray
int Sum = 0;
for(int k = 0;k<SIZE;k ){
Sum += thirdArray[k];
}
cout << "the arithmetic average third line: " << Sum/SIZE << endl;
//max value thirdArray
int max=thirdArray[0];
for(int k = 1;k max)
max =thirdArray[k];
}
cout << "max value third line: " << max << endl;
//min value thirdArray
int min = thirdArray[0];
for(int k = 1;k<SIZE;k ){
if (thirdArray[k] < min)
min = thirdArray[k];
}
cout << "min value third line: " << min << endl;
return 0;
}
#include
#include
using namespace std;
int main() {
srand(time(NULL));
int arr[50],a;
for (int i = 0; i < 50; i )
{m1:
a=rand() % 100;
if (a % 2 != 0) { arr[i] = a; }
else goto m1;
cout << arr[i] << endl;
}
}
Goal number 2
задание номер 2 надо уточнить. а именно укажите что рандомными нечетными числами надо заполнить.