Home > Back-end > CSP bo, who is a great god help me have a look at ahhh
CSP bo, who is a great god help me have a look at ahhh
Time:11-20
Did not know where is the problem? The code below #include using namespace std;
Int main () { Int n=0, a=0, b=0; Int consult=0; Cin> n> A> b; Int indew_u [a]={0}, value_u [a]={0}, indew_v [b]={0}, value_v [b]={0}; Int I=0, j=0; for(i=0; iCin> Indew_u [I] & gt;> Value_u [I]; } for(j=0; jCin> Indew_v [j] & gt;> Value_v [j]; } i=0; j=0; while(i{ If (indew_u [I] i++; Else if (indew_u [I] & gt; Indew_v [j]) j++; Else if (indew_u [I]==indew_v [j]) { Consult +=value_u value_v [I] * [j]; i++; j++; } } Coutreturn 0; }
Initially has been running a timeout, 30 points, and then I put the double loop into a single, and display operation error, don't know what wrong?
CodePudding user response:
Dynamic array to use new or malloc allocates memory Int indew_u [a]={0}, value_u [a]={0}, indew_v [b]={0}, value_v [b]={0}; Change Int * indew_u=new int [a] {0}, * value_u=new int [a] {0}, * indew_v=new int [b] {0}, * value_v=new int [b] {0};
Finally, don't forget to release the memory The delete [] indew_u; The delete [] value_u; The delete [] indew_v; The delete [] value_v;