student{
no: '2021{{integer(100,999)}}',
name: '{{random("张三", "李四", "王五")}}',
age: '{{integer(18, 22)}}',
gender: '{{gender()}}',
email: '{{email()}}',
phone: '{{phone()}}',
address: '{{city()}}',
clazz: '2021级{{integer(10,10)}}班',}
#include<iostream>
#include<string>
#include<algorithm>
#include<time.h>
using namespace std;
class student
{
public:
int no()
{
return 2021 * 1000 + rand() % 900 + 100;
}
int age()
{
return rand() % 5 + 18;
}
string name()
{
string s[3] = { "张三","李四","王五" };
return s[rand() % 3];
}
string gender()
{
string s[2] = {"男","女"};
return s[rand() % 2];
}
string email()
{
char e[20];
for (int i = 0; i < 20; i++)
{
e[i] = rand() % 30 + 97;
}
e[19] = '\0';
e[10] = '@';
return e;
}
long long phone()
{
return rand() % 90000000000 + 10000000000;
}
string address()
{
}
string clazz()
{
string s1 = "2021级", s2 = "班";
s1.push_back(rand() % 10 + 1 + '0');
return s1 + s2;
}
};
int main()
{
srand((unsigned int)time(NULL));
student s;
cout << s.age() << endl << s.clazz() << endl << s.email() << endl
<<s.name()<<endl<< s.gender() << endl << s.no()<< endl << s.phone() << endl;
}