how to get input in 2d array in c
#include <stdio.h> int main(){ printf("Enter the number of columns"); int i; scanf("%d", &i); printf("Enter the number of rows"); int y; scanf("%d", &y); int r[i][y]; int a; int b; for (a=0; a<i; a++){ for (b=0; b<y; b++){ scanf("%d",&r[a][b]); } } }
Source: stackoverflow.com
how to take input in 2d vector in c++
std::vector<vector<int>> d; //std::vector<int> d; cout<<"Enter the N number of ship and port:"<<endl; cin>>in; cout<<"\Enter preference etc..:\n"; for(i=0; i<in; i++){ cout<<"ship"<<i+1<<":"<<' '; for(j=0; j<in; j++){ cin>>temp; d.push_back(temp);// I don't know how to push_back here!! } }
Source: stackoverflow.com
how to take input from user in 2d array in c++
#include<stdio.h> #include<conio.h> int main() { printf("Enter the number of columns"); int i; scanf("%d", &i); printf("Enter the number of rows"); int y; scanf("%d", &y); int r[i][y]; int a; int b; for (a = 0; a < i; a++) { for (b = 0; b < y; b++) { scanf("%d", &r[a][b]); } } return 0; }