标签:linux fine srand def printf and i++ lin efi
code:
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <time.h> 4 5 #define random_1(a, b) ((rand()%(b - a)) + a) 6 #define random_2(a, b) ((rand()%(b - a + 1)) + a) 7 8 int main(int argc, char **argv) 9 { 10 srand((int)time(NULL)); 11 int arr[10]; 12 for(int i = 0; i < 10; i++){ 13 arr[i] = random_1(1, 20); 14 } 15 16 for(int i = 0; i < 10; i++){ 17 printf("%d\t", arr[i]); 18 } 19 20 21 return 0; 22 }
标签:linux fine srand def printf and i++ lin efi
原文地址:https://www.cnblogs.com/guochaoxxl/p/11889772.html