Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <clocale>
- using namespace std;
- const int n = 6, m = n + 1;
- void printArray(double *x) {
- for (int i = 0; i < n; i++) {
- cout << setprecision(2) << x[i] << ' ';
- }
- cout << '\n';
- }
- void printMatrix(double x[][m]) {
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- cout << setprecision(2) << setw(6) << x[i][j];
- }
- cout << '\n';
- }
- }
- int main() {
- srand(time(NULL));
- setlocale(LC_ALL, "rus");
- double a[n], mat[n][m];
- for (int i = 0; i < n; i++) {
- a[i] = (double) rand() / RAND_MAX * 21 - 10;
- }
- printArray(a);
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < m; j++) {
- if (j == 5)
- mat[i][j] = a[i];
- else
- mat[i][j] = (double) rand() / RAND_MAX * 21 - 10;
- }
- }
- printMatrix(mat);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment