Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL,"");
- srand(time(0));
- int a[6][4];
- for (int i = 0; i < 4; i++)
- for (int j = 0; j < 6; j++)
- a[i][j]=rand()%10;
- cout << "Исходная матрица имеет вид : \n\n";
- for (int i = 0; i < 4; i++)
- {
- for (int j = 0; j < 6; j++)
- {
- cout << a[i][j] << " ";
- }
- cout << endl;
- }
- int Sum = 0, Comp = 1;
- for (int i = 0; i < 4; i++)
- {
- for (int j = 0; j < 6; j++)
- {
- if ((i+j)%2!=0)
- {
- Sum += a[i][j];
- Comp *= a[i][j];
- }
- }
- }
- cout << "\nСумма нечетных элементов равна : " << Sum;
- cout << "\nПроизведение нечетных элементов равно : " << Comp << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement