June 25th, 2012, 09:11 PM
#1
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.
June 26th, 2012, 01:15 AM
#2
Re: How to select the first n terms?
Use std::vector instead of a plain array.
Victor Nijegorodov
June 26th, 2012, 07:10 AM
#3
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.
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks