daily pastebin goal
29%
SHARE
TWEET

цифри

masterm1nd99 Jan 11th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. void writeToFile() {
  4.     FILE *f = fopen("text.txt", "w");
  5.     char c;
  6.     while((c = getchar()) != '#') {
  7.         fputc(c, f);
  8.     }
  9.     fclose(f);
  10. }
  11.  
  12. int main() {
  13.     writeToFile();
  14.     float l=0, br=0;
  15.     char ch;
  16.     FILE *f1;
  17.     if ((f1 = fopen("text.txt", "r")) == NULL) {
  18.         printf ("Datotekata ne se otvara");
  19.         return -1;
  20.     }
  21.     while ((ch = fgetc(f1))!=EOF) {
  22.         if (isalpha(ch)) {
  23.             l++;
  24.         }
  25.         if (isdigit(ch)) {
  26.             br++;
  27.         }
  28.     }
  29.     printf("%.2f",br/l);
  30.     fclose(f1);
  31.     return 0;
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top