Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- #include <string.h>
- #include <stdlib.h>
- char* genset(int num, int max, int mod) {
- char *temp;
- do {
- temp = (char *)calloc(num+1, sizeof(char));
- for(int i=0; i<num; i++)
- sprintf(temp, "%s%d", temp, (rand()%mod));
- } while(atoi(temp)>max);
- return temp;
- }
- int main(int argc, char **argv) {
- srand(time(NULL));
- printf("%s-%s-%s\n", genset(3, 999, 8), genset(3, 742, 10), genset(4, 9999, 10));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement