#include<random>
#include<time.h>
#include<assert.h>
#include<iostream>
using namespace std;
int main()
{
srand(time(0));
while(1)
{
int start = rand()%10;// the start of the loop (included)
int end = rand()%10 + 100;//the end of the loop (not included)
int step = rand()%5 + 1;//step length
int loop_count = 0;
if((end - start)%step ==0)
{
loop_count = (end - start)/step;
}
else
{
loop_count = (end - start)/step + 1;
}
int count = 0;
for(int i =start; i< end;i+=step)
{
count++;
}
cout<<"start "<<start<<endl;
cout<<"end "<<end<<endl;
cout<<"step "<<step<<endl;
cout<<"loop_count "<<loop_count<<endl;
cout<<"count "<<count<<endl;
assert(count == loop_count);
}
return 0;
}