using namespace std;
int main(int argc, char** argv) { int i=0,t, s,suma; cin>>t; for(int i;i<=t;i++){ int suma=0; cin>>s; int tab[t][s]; for(int j=0;j<s;j++){ cin>>tab[i][j]; suma+=tab[i][j]; } cout<<suma+s-1<<endl; }
return 0;
}
First of all, please tell us what problem is it, and what's your idea - Not just the code.
The condition of for loop is wrong.for(int i //here new i will be initialised with garbage value
i will try to write this program again.
You are also trying to run the outer loop t + 1 times instead of t times. Then in that case the declaration int tab[t][s] would give segmentation fault when accessing tab[i][j] where i == t