Advertisement
CosmicFox33

blya228.1

Dec 3rd, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <conio.h>
  4. #include <locale.h>
  5. #define fmax 21
  6. #define abc "ABCDEFGHIJ"
  7.  
  8. int main()
  9. {
  10. system("chcp 1251");
  11. system("cls");
  12. setlocale(LC_ALL, "Russian");
  13. FILE *I, *O;
  14. int col, slen, len, flag_file;
  15. char i[fmax], o[fmax], c;
  16. printf("Введите название входного файла (длина не должна превышать %d): ", fmax-1);
  17. scanf("%s", i);
  18. printf("Введите название выходного файла (длина не должна превышать %d): ", fmax-1);
  19. scanf("%s", o);
  20.  
  21. O=fopen(o, "w+");
  22. I=fopen(i, "r");
  23.  
  24. col=0;
  25. flag_file=1;
  26.  
  27. while(fscanf(I, "%c", &c)!=EOF)
  28. {
  29. if(c!='\n')
  30. {
  31. slen++;
  32. if((c>='0'&&c<='9'))
  33. {
  34. fprintf(O, "%c", abc[(int)c-48]);
  35. printf("%c", abc[(int)c-48]);
  36. flag_file=0;
  37. }
  38. else
  39. {
  40. fprintf(O, "%c", c);
  41. printf("%c", c);
  42. }
  43. }
  44. else
  45. {
  46. fprintf(O, "\n");
  47. printf("\n");
  48. }
  49.  
  50. }
  51. if(flag_file)
  52. {
  53. fprintf(O, "\nФайл не был изменён.\n");
  54. printf("\nФайл не был изменён.\n");
  55. }
  56. fclose(O);
  57. fclose(I);
  58.  
  59. return 0;
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement