geek_stuff/today
Linear Shifted Array Generator
!kKo
2006. 5. 31. 09:20
Linear Shifted Array Generator by !kKo
output_file<<((end-start)/shift)+1<<endl; // number of entries...
int j=0;
for (int i=start; i<=end; i=i+shift) // making array
{
array[j++]=i;
}
// Uncomment the following line to display the whole array.
// for (i=0;i<(end-start)/shift;i++){cout<<array[i]<<" ";} cout<<endl;
for (i=shift;i<=(end-start)/shift;i++) // writing to file
{
output_file<<array[i]<<" ";
}
for (i=0;i<shift;i++) // writing to file
{
output_file<<array[i];
if(i<shift-1) output_file<<" ";
}
output_file<<endl;
int j=0;
for (int i=start; i<=end; i=i+shift) // making array
{
array[j++]=i;
}
// Uncomment the following line to display the whole array.
// for (i=0;i<(end-start)/shift;i++){cout<<array[i]<<" ";} cout<<endl;
for (i=shift;i<=(end-start)/shift;i++) // writing to file
{
output_file<<array[i]<<" ";
}
for (i=0;i<shift;i++) // writing to file
{
output_file<<array[i];
if(i<shift-1) output_file<<" ";
}
output_file<<endl;
Download Full Source Code