Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.  
  6. FILE *fp, *fd, *fv;
  7.  
  8.  
  9. fp = fopen("cisla1.txt","r");
  10. fd = fopen("cisla2.txt","r");
  11. fv = fopen("vysledok.txt","w");
  12. int cisla1;
  13. int cisla2;
  14.  
  15. int prvy = fscanf(fp,"%d",&cisla1);
  16. int druhy = fscanf(fd,"%d",&cisla2);
  17.  
  18.  
  19. while (prvy > 0 || druhy > 0) {
  20. while (prvy > 0 && (druhy<=0 || cisla1 <= cisla2))
  21. {
  22. fprintf(fv, "%d ", cisla1);
  23. prvy = fscanf(fp, "%d", &cisla1);
  24. }
  25. while (druhy > 0 && (prvy<=0 || cisla2 <= cisla1))
  26. {
  27. fprintf(fv, "%d ", cisla2);
  28. druhy = fscanf(fd, "%d", &druhy);
  29. }
  30. }
  31.  
  32.  
  33.  
  34. fclose(fp);
  35. fclose(fd);
  36. fclose(fv);
  37.  
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement