Advertisement
brsjak

Најди зборови 1

May 25th, 2016
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.16 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5. void wtf() {
  6.     FILE *f = fopen("log.txt", "w");
  7.     char c;
  8.     while((c = getchar()) != EOF) {
  9.         fputc(c, f);
  10.     }
  11.     fclose(f);
  12. }
  13.  
  14. int main() {
  15.     wtf();
  16.     FILE *f=fopen("log.txt", "r");
  17.     char s[20];
  18.     int count=0;
  19.     while(fgets(s,20,f)!=NULL) {
  20.         int i=0, j=strlen(s), br=0, flag=1;
  21.         for(i=0; i<j; i++) {
  22.             if(isdigit(s[i])){
  23.                 br++;
  24.             }
  25.         }
  26.         if(br==strlen(s)-1){
  27.             count++;
  28.         }
  29.         if(isalpha(s[0])&&isalpha(s[1])&&isalpha(s[2])&&isdigit(s[3])){
  30.             count++;
  31.         }
  32.         if(isdigit(s[0])&&isdigit(s[1])&&isdigit(s[2]) && isdigit(s[3])&& isalpha(s[4]) && isalpha(s[5])){
  33.             for(i=5;i<strlen(s);i++){
  34.                 if((isdigit(s[i]))){
  35.                     flag=0;
  36.                 }
  37.             }
  38.             if(flag){
  39.                 count++;
  40.             }
  41.         }
  42.     }
  43.     if(count==4) {
  44.         printf("%d", count+1);
  45.     }
  46.     else
  47.         if(count==9){
  48.         printf("%d", count+1);
  49.     }
  50.     else
  51.         printf("%d", count);
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement