#include <cstdlib> #include <cstdio> #include <iostream> using namespace std; //глобальная константа: const int n=3; const int n1=2; //Функция для отображения элементов двумерного массива: void show(int M[n][n1]){ for(int i=0;i<n;i++){ for(int j=0;j<n1;j++){ //Оторажение элементов массива: printf("%4d",M[i][j]); } //Переход к новой строке: printf("\n"); } } int fam; int fam1; int fam2; //Главная функция программы: int main(){ //Изменение кодировки консоли: system("chcp 1251>nul"); cout<<"Ваше фамилия - " ; cin>>fam; cout<<"Ваше фамилия - " ; cin>>fam1; cout<<"Ваше фамилия - " ; cin>>fam2; //Объявление и инициализация двухмерного массива: int A[n][n1]={{fam,231},{fam1,231},{fam2,231}}; printf("Матрица А:\n"); //Оторажение содержимого массива: show(A); return 0; } - oneWhat is your name instead of the number? - VTT
- What did you want to do? - AR Hovsepyan
- cout << "Your Last Name -"; then you probably enter a string that the program forces to convert to an integer number, which will lead to undefined behavior or will give 0 (did not try to do this) - AR Hovsepyan
- Agree with AR Hovsepyan. And how to fix it? - igorekvp
- create your class and use containers std - Nikita Samoukov
|