1:问题如上?
2:如何实现保留两位小数点及如何四舍五入?
1:
#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 99\n\n"); for(i=0; i<10; i++) printf("%d\n", rand() % 100); return 0; }
2:
#include <stdlib.h> #include <stdio.h> #include <time.h>
int main(void) { int i;
randomize(); printf("Ten random numbers from 0 to 99\n\n"); for(i=0; i<10; i++) printf("%d\n", rand() % 100); return 0; } 3:
#include <stdlib.h> #include <stdio.h> #include <time.h>
/* prints a random number in the range 0 to 99 */ int main(void) { randomize(); printf("Random number in the 0-99 range: %d\n", random (100)); return 0; }