0
How to produce a random vehicle number (i.e RJ14CG3894) using rand() function ?
It must consist of state code such as RJ or MP... or such followed by two alphabets and 4 digit Numbers. C++
3 odpowiedzi
+ 13
//==========================
// Vehicle number generator
// Done for: bhuwan Chandna
// By : Babak Sheykhan
//==========================
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
srand(static_cast<size_t>(time(0)));
string num = "xxyyxxyyyy"; // x: letter, y: number
for (auto i = 0; i < num.length(); ++i) {
if (num.at(i) == 'x') num.at(i) = 65 + rand() % (91 - 65);
else num.at(i) = 48 + rand() % (58 - 48);
}
cout << num;
}
[https://code.sololearn.com/cM7oGReNXXqe]
+ 13
Student must listen to his mentor more than ever. Thank you dear JPM7. @~)~~~~
+ 7
What's the vehicle numbers' syntax?