C/C++

Решить задания с массивами и циклами

Ex. 1
Generate array of random numbers and write a loop that finds the minimum element in the array.

Ex. 2
Write the sequence into array
5 10 15 20 ...

Ex. 3
Write a program to take from users single letters and put them to array. Print array.

Ex. 4
Write a pattern into array. Ask user how many times he want to put the pattern into array.
-<*>-

Ex. 5
Generate array of random integer numbers. Range is 10. User desides the size of the array. Count how many 5 you have.

Ex. 6
Write a program to take from user floating point values and write them in array. Every element of array raise it to the 2nd power. Print output.

Ex. 7
Generate array of random numbers. Ask user for the size of the array. Count mean of all values from the array.

Ex. 8
Write a program to take from user floating point values and write them in array. Print only elements with index, which is an odd number.

Ex. 9
Generate array of random numbers. Write a program to copy into new array numbers greater than 10.

Ex. 10
Generate array with ASCII symbols.

Ex. 11
Write a program to take from user two words and check if they are equal.

Ex. 12
Write a program to take from user word. Count occurrence of each letter in its word.
Написать желательно на C++
Ex. 1
#include <iostream>
#include <ctime>
using namespace std;

int main() {
int ar[20];
srand(time(0));
for (int& i : ar) i = rand() % 501;
int min = ar[0];
for (int i : ar) {
if (i < min) min = i;
}
cout << min;
return 0;
}

Ex. 2
#include <iostream>
using namespace std;

int main() {
int ar[20];
for (int i = 0, v = 5; v <= 100; ++i, v += 5) {
ar[i] = v;
}
for (int item : ar) cout << item << " ";
return 0;
}
ЖК
Жека Коноваленко
6 243
Лучший ответ
//Ex. 10
#define LENGTH 256
#include <iostream>

int main()
{
char symbols[LENGTH];
for (signed int i = 0; i < LENGTH; i++) {
symbols[i] = i-128;
std::cout << symbols[i] << " ";
};
};

//Ex. 11
#include <iostream>
#include <string>

int main()
{
std::string S1, S2;
std::cin >> S1 >> S2;
std::cout << S1.size() << " " << S2.size() << std::endl;
if (S1.size() == S2.size()) {
for (int i = 0; i < S1.size(); i++) {
if (std::isupper(S1[i])) S1[i] = std::tolower(S1[i]);
if (std::isupper(S2[i])) S2[i] = std::tolower(S2[i]);
};
std::cout << S1 << " " << S2 << std::endl;
if (S1 == S2) std::cout << "Strings equal!" << std::endl << S1 << " " << S2 << std::endl;
}
else std::cout << "Strings are not equal!" << std::endl << S1 << " " << S2 << std::endl;
};

В 11 задании сделал упразднение регистра, в случае если нужно полное сравнение - нужно убрать почти все конструкции кроме if (S1 == S2)...