Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include<stdio.h>
  2. #define N 5
  3.  
  4. int main(void)
  5. {
  6. FILE *f_out;
  7. errno_t file_1;
  8. file_1 = fopen_s(&f_out, "new_text.txt", "w+");
  9.  
  10. int mas[N];
  11. for (int i = 0; i < N; i++) //ввод массива
  12. {
  13. scanf_s("%d", &mas[i]);
  14. }
  15.  
  16. int *ptr;
  17. ptr = mas;
  18.  
  19. for (int i = 0; i < N; i++)
  20. {
  21. if (*ptr < 0) *ptr = 0;
  22. for (int j = 0; j < *ptr; j++)
  23. {
  24. fprintf(f_out, "%d ", *ptr);
  25. }
  26. fprintf(f_out,"\n");
  27. //запись строк в файл
  28. ptr++;
  29. }
  30.  
  31.  
  32. fclose(f_out);
  33.  
  34.  
  35. system("pause");
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement