How to select the first n terms?
Code:
for(i=0;i<500;i++)
{
x=valuex[i];
y=valuey[i];
A[i][0]=x+y;
A[i][1]=x*x+3*y;
A[i][2]=x+2*y*x;
……
A[i][99]=x/2+20*y;
}
In the above code,there are 100 terms:A[i][0]~A[i][100], In fact, I want to use the first n terms of A[i][j],and "n" is the input number by user, how can I realize this efficiently,Thank you for your help.
Best wishes.
Re: How to select the first n terms?
Use std::vector instead of a plain array.
Re: How to select the first n terms?
You could certainly benefit from a second loop rather than hardcoding the indices. Use n as the loop condition to control the count.