Advertisement
chillminotaurs5

randomgen

Apr 19th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main(){
  6.     int tam, num, n;
  7.     srand((unsigned)time(NULL));
  8.     FILE *input;
  9.     input = fopen("2.in", "w");
  10.     if(input==NULL){
  11.         printf("Erro1\n");
  12.         exit(1);
  13.     }
  14.     scanf("%d", &tam);
  15.     while(tam--){
  16.         num = rand()%9;
  17.         fprintf(input, "%d\n", num);
  18.     }
  19.     fclose(input);
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement