第一个问题:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void)
{
int i;
time_t t;
srand((unsigned) time(&t));
printf("Ten random numbers from 0 to 10\n\n");
printf("%d\n", rand()%10+1);
return 0;
}
第二个问题:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void)
{
int i,a[7]={2,4,5,6,7,11,14};
time_t t;
srand((unsigned) time(&t));
i=rand()%7;
printf("%d\n",a[i]);
return 0;
}