generated from sigonasr2/CPlusPlusProjectTemplate
Part 2 done!
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
7998b707a5
commit
3c172fc810
Binary file not shown.
28
main.cpp
28
main.cpp
@ -5,7 +5,7 @@
|
||||
using namespace olc;
|
||||
|
||||
struct Data{
|
||||
int value; //Number.
|
||||
long value; //Number.
|
||||
int position; //Current position in the list.
|
||||
};
|
||||
|
||||
@ -19,16 +19,26 @@ int main()
|
||||
std::getline(file,line);
|
||||
//std::cout<<line<<std::endl;
|
||||
if (line.length()>0){
|
||||
Data*data=new Data{std::atoi(line.c_str()),(int)originalSet.size()};
|
||||
Data*data=new Data{std::atoi(line.c_str())*811589153l,(int)originalSet.size()};
|
||||
originalSet.push_back(data);
|
||||
newSet.push_back(data);
|
||||
}
|
||||
}
|
||||
std::cout<<std::endl;
|
||||
for (int i=0;i<newSet.size();i++){
|
||||
if (i!=0){
|
||||
std::cout<<",";
|
||||
}
|
||||
std::cout<<newSet[i]->value<<" ["<<newSet[i]->position<<"]";
|
||||
}
|
||||
std::cout<<std::endl;
|
||||
for (int j=0;j<10;j++){
|
||||
for (int i=0;i<originalSet.size();i++){
|
||||
Data*val=originalSet[i];
|
||||
int pos=val->position;
|
||||
Data*temp=newSet[pos];
|
||||
int shift=val->value;
|
||||
long shift=(val->value)%(long)(originalSet.size()-1l);
|
||||
std::cout<<"Shift value is "<<shift<<std::endl;
|
||||
while (shift!=0){
|
||||
if (shift>0){
|
||||
//Move it to the right of the list.
|
||||
@ -66,6 +76,16 @@ int main()
|
||||
}
|
||||
std::cout<<std::endl;*/
|
||||
}
|
||||
std::cout<<std::endl;
|
||||
std::cout<<"Round "<<j+1<<std::endl;
|
||||
for (int i=0;i<newSet.size();i++){
|
||||
if (i!=0){
|
||||
std::cout<<",";
|
||||
}
|
||||
std::cout<<newSet[i]->value<<" ["<<newSet[i]->position<<"]";
|
||||
}
|
||||
std::cout<<std::endl;
|
||||
}
|
||||
|
||||
Data*zeroVal;
|
||||
|
||||
@ -84,7 +104,7 @@ int main()
|
||||
std::cout<<"2000: "<<newSet[offset2]->value<<std::endl;
|
||||
std::cout<<"3000: "<<newSet[offset3]->value<<std::endl;
|
||||
|
||||
int sum=newSet[offset]->value+newSet[offset2]->value+newSet[offset3]->value;
|
||||
long sum=newSet[offset]->value+newSet[offset2]->value+newSet[offset3]->value;
|
||||
std::cout<<"Sum: "<<sum<<std::endl;
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user