Guest User

Untitled

a guest
Feb 19th, 2020
77
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <stdlib.h>
  4.  
  5. int main()
  6. {
  7. FILE *f;
  8. char filename[256];
  9. int c; int chars = 0; int lines = 0; int letters = 0; int digits = 0; int uppers = 0; int lowers = 0 ; int spaces = 0; int puncts = 0; int glas = 0; int sogl = 0;
  10. printf("Введите имя файла \n");
  11. scanf("%s", filename);
  12. f=fopen(filename,"r");
  13. if (!f)
  14. {
  15. printf("Файл не найден \n");
  16. return 0;
  17. }
  18. while((c=fgetc(f)) !=EOF)
  19. {
  20. chars++;
  21. if(c == '\n') lines++;
  22. if(isalpha(c)) letters++;
  23. if(isdigit(c)) digits++;
  24. if(isspace(c)) spaces++;
  25. if(isupper(c))uppers++;
  26. if(islower(c)) lowers++;
  27. if(ispunct(c)) puncts++;
  28. }
  29.  
  30. switch(c)
  31. {
  32. case 'a':
  33. case 'e':
  34. case 'i':
  35. case 'o':
  36. case 'u':
  37. case 'y': glas++; break;
  38. default: sogl++;
  39. }
  40.  
  41. printf("%d", chars, "Символов");
  42. printf("%d", lines, "Строк");
  43. printf("%d", digits, "Цифр");
  44. printf("%d", spaces, "Пробелов");
  45. printf("%d", uppers, "С верхним регистром");
  46. printf("%d", lowers, "С нижним регистром");
  47. printf("%d", puncts, "Знаков пунктуации");
  48. printf("%d", glas, "Гласных");
  49. printf("%d", sogl, "Согласных");
  50. }
RAW Paste Data