+ 1

Why cpp show me a error when I write this: string c[n][m];

20th Apr 2018, 5:35 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
10 Réponses
+ 1
The first element is at array[0], not array[1]. This could be the reason.
21st Apr 2018, 7:19 AM
Timon Paßlick
0
I know it work with it but you don't with this m n
20th Apr 2018, 6:20 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
I dont have declaration size of array
20th Apr 2018, 6:24 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
yes
20th Apr 2018, 6:28 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
look my code
20th Apr 2018, 6:32 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
#include <iostream> using namespace std; int main (){ int n,m,i,j; cin>>n; char a[n]; for (i=1;i<=n;i++) cin>>a[i]; cin>>m; string c[m][n]; char b[m]; for (i=1;i<=m;i++) cin>>b[i]; for (i=1;i<=n;i++) for (j=1;j<=m;j++) c[i][j]=a[i]+b[j]; for (i=1;i<=n;i++){ for (j=1;j<=m;j++) cout<<c[i][j]<<" "; cout<<endl; } }
20th Apr 2018, 6:32 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
yes
20th Apr 2018, 6:36 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
no output
20th Apr 2018, 6:37 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
I try but nothing
20th Apr 2018, 6:41 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar
0
make a 2d array with don't declaration size type string
20th Apr 2018, 6:46 PM
Cлaвeн Ђервида
Cлaвeн Ђервида - avatar