Created
July 22, 2019 14:53
-
-
Save 08vivek08/ff14386a8d5336904996f1cff2c9c8da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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