Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main() {
- srand(time(NULL));
- setlocale(LC_ALL, "ru");
- const int ROW = 6;
- const int COL = 6;
- float a[ROW][COL];
- float b[3][6];
- int ans;
- bool x;
- cout << "Нажмите 1, если Вы хотите заполнить матрицу самостоятельно" <<
- " и 0, если требуется автоматическое её заполнение:";
- cin >> ans;
- if (ans == 1) {
- for (int i = 0; i < ROW; i++) {
- for (int j = 0; j < COL; j++) {
- cin >> a[i][j];
- }
- }
- for (int i = 0; i < ROW; i++) {
- cout << endl;
- for (int j = 0; j < COL; j++) {
- cout << a[i][j] << " ";
- }
- }
- }
- else if (ans == 0) {
- for (int i = 0; i < ROW; i++) {
- int randNum = rand() % 100;
- for (int j = 0; j < COL; j++) {
- a[i][j] = rand() % 100;
- }
- }
- for (int i = 0; i < ROW; i++) {
- cout << endl;
- for (int j = 0; j < COL; j++) {
- cout << a[i][j] << " ";
- }
- }
- }
- cout << endl;
- for (int j = 0; j < COL; j++) {
- if (a[0][j] == 0) {
- cout << 0 << " ";
- }
- else {
- cout << fixed << setprecision(1) << a[1][j] / a[0][j] << " ";
- }
- }
- cout << endl;
- for (int j = 0; j < COL; j++) {
- if (a[2][j] == 0) {
- cout << 0 << " ";
- }
- else {
- cout << fixed << setprecision(1) << a[3][j] / a[2][j] << " ";
- }
- }
- cout << endl;
- for (int j = 0; j < COL; j++) {
- if (a[4][j] == 0) {
- cout << 0 << " ";
- }
- else {
- cout << fixed << setprecision(1) << a[5][j] / a[4][j] << " ";
- }
- }
- cout << endl;
- //в итоге получилось создать массив и делить четные строки на нечетные
- //теперь нужно либо видоизменить старый массив и сделать 3x6
- //либо создать новый и поместить туда результат деления
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement