T
tes64dk
Guest
Hey all,
I know this is super trivial to most of you, but I'm having some trouble with my logic here.
I am trying to move a the number "1" down a vector length 6. so it will start of with all zeros and move that "1" down.
Example: 0 0 0 0 0 0, 1 0 0 0 0 0, 0 1 0 0 0 0, 0 0 1 0 0 0, 0 0 0 1 0 0, 0 0 0 0 1 0, 0 0 0 0 0 1
After that, theres another vector length 12 that continues after the "1" position in the previous vector reaches position 6.
Example: 0 0 0 0 0 0 | 1 0 0 0 0 0 0 0 0 0 0 0, 0 0 0 0 0 0 | 0 1 0 0 0 0 0 0 0 0 0 0, 0 0 0 0 0 0 | 0 0 1 0 0 0 0 0 0 0 0 0 keep moving that "1" down until every entry is "0" except the 12th position.
Here's what I have done. It just gives me all "1's" when I run it.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
vector<int> dBodyVelocity(6,0);
vector<int> qdd(12,0);
for(int x=0; x<18; x++)
if( x<6 ){
dBodyVelocity[x]=1;
dBodyVelocity[x-1]=0;
if (x==5){
dBodyVelocity[x]=0;
}
for(int y=0;y<6;x++)
cout << dBodyVelocity[y] << " ";
}
else{
qdd[x]=1;
qdd[x-1]=0;
// for (int x : dBodyVelocity)
// cout << x << " ";
//for (int x : qdd)
//cout << x << " ";
return 0;
}
}
Continue reading...
I know this is super trivial to most of you, but I'm having some trouble with my logic here.
I am trying to move a the number "1" down a vector length 6. so it will start of with all zeros and move that "1" down.
Example: 0 0 0 0 0 0, 1 0 0 0 0 0, 0 1 0 0 0 0, 0 0 1 0 0 0, 0 0 0 1 0 0, 0 0 0 0 1 0, 0 0 0 0 0 1
After that, theres another vector length 12 that continues after the "1" position in the previous vector reaches position 6.
Example: 0 0 0 0 0 0 | 1 0 0 0 0 0 0 0 0 0 0 0, 0 0 0 0 0 0 | 0 1 0 0 0 0 0 0 0 0 0 0, 0 0 0 0 0 0 | 0 0 1 0 0 0 0 0 0 0 0 0 keep moving that "1" down until every entry is "0" except the 12th position.
Here's what I have done. It just gives me all "1's" when I run it.
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
vector<int> dBodyVelocity(6,0);
vector<int> qdd(12,0);
for(int x=0; x<18; x++)
if( x<6 ){
dBodyVelocity[x]=1;
dBodyVelocity[x-1]=0;
if (x==5){
dBodyVelocity[x]=0;
}
for(int y=0;y<6;x++)
cout << dBodyVelocity[y] << " ";
}
else{
qdd[x]=1;
qdd[x-1]=0;
// for (int x : dBodyVelocity)
// cout << x << " ";
//for (int x : qdd)
//cout << x << " ";
return 0;
}
}
Continue reading...