Skip to content

Instantly share code, notes, and snippets.

@08vivek08
Created July 22, 2019 14:53
Show Gist options
  • Save 08vivek08/ff14386a8d5336904996f1cff2c9c8da to your computer and use it in GitHub Desktop.
Save 08vivek08/ff14386a8d5336904996f1cff2c9c8da to your computer and use it in GitHub Desktop.
/* 1. Randomly generate any code of four digit no with
unit as a fibboniccai no & prime no
tenth & hundred place difference as 2
hundred & thousand place difference as 2
*/
#include <bits/stdc++.h>
using namespace std;
int arr[]={2,3,5};
int code_gen(){
srand(time(NULL));
int i = rand()%3;
int code;
int unit = arr[i];
int ten = rand()%(6);{
while(ten==unit || unit==ten+2 || unit==ten+4){
ten = rand()%(6);
}
}
code = (ten+4)*1000 + (ten+2)*100 + ten*10 + unit;
return code;
}
int main(){
int code = code_gen();
cout<<code;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment