Advertisement
JanevFilip

Datoteki

Jan 30th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.98 KB | None | 0 0
  1. Zborovi so najmalku 2 cifri i 3 bukvi
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #define MAX 100
  7. int main()
  8. {   FILE *f=fopen("input.txt","r");
  9.     FILE *k=fopen("output.txt","w");
  10.     int cifri=0,bukvi=0,n,i,zborovi;
  11.     char red[MAX];
  12.         while(fgets(red,MAX,f))
  13.         {
  14.             n=strlen(red);
  15.             i=0;
  16.                 while(i<n)
  17.                 {
  18.                     if(isalnum(red[i]))
  19.                     {
  20.                         if(isdigit(red[i]))
  21.                         {
  22.                             cifri++;
  23.                         }
  24.                         if(isalpha(red[i]))
  25.                         {
  26.                             bukvi++;
  27.                         }
  28.                     }
  29.                 }
  30.                 if(cifri>=2&&bukvi>=3)
  31.                 {
  32.                     zborovi++;
  33.                 }
  34.                 else
  35.                 {
  36.                     //cifri=0;
  37.                     //bukvi=0;
  38.                     zborovi=0;
  39.                 }
  40.                 cifri=0;
  41.                 bukvi=0;
  42.                 if(zborovi>0)
  43.                 {
  44.                     printf("%s",red);
  45.                 }
  46.         }
  47.  
  48.  
  49. Broj na samoglaski
  50. #include <stdio.h>
  51. #include <stdlib.h>
  52. #include <string.h>
  53. #define MAX 100
  54. int main()
  55. {   FILE *f=fopen("input.txt","r");
  56.  
  57.     int i,n,samoglaski=0,max=-999;
  58.     char red[MAX],zbor[MAX];
  59.         while(fgets(red,MAX,f))
  60.         {
  61.             n=strlen(red);
  62.             i=0;
  63.                 while(i<n)
  64.                 {
  65.                     if(red[i]=='a'||red[i]=='e'||red[i]=='u'||red[i]=='i'||red[i]=='o')
  66.                     {
  67.                         samoglaski++;
  68.                     }
  69.                     i++;
  70.                 }
  71.                 if(max<samoglaski)
  72.                 {
  73.                     max=samoglaski;
  74.                     strcpy(zbor,red);
  75.                 }
  76.         }
  77.         fprintf("%s",zbor);
  78.     return 0;
  79. }
  80.  
  81. Broj na zborovi koi imaat poveke od 2 cifri
  82.  
  83. #include <stdio.h>
  84. #include <stdlib.h>
  85. #include <ctype.h>
  86. #include <string.h>
  87. #define MAX 100
  88. int main()
  89. {
  90.     FILE *f=fopen("input.txt","r");
  91.     FILE *k=fopen("output.txt","w");
  92.     char red[MAX];
  93.     char c;
  94.     int a, b,i;
  95.  
  96.     while (fgets(red,MAX,f)!=NULL)
  97.     {
  98.  
  99.         int counter2=0;
  100.         int counter=0;
  101.         for(i=0;i<strlen(red);i++){
  102.  
  103.             if(isalnum(red[i]))
  104.         {
  105.             if(isdigit(red[i]))
  106.             counter++;
  107.             //printf("%d ",counter);
  108.         }
  109.             else{
  110.                  if(counter<=2)
  111.             {
  112.                 counter=0;
  113.                 continue;
  114.             }
  115.             else{
  116.                 counter2++;
  117.                 counter=0;
  118.                 //printf("%d ", counter2);
  119.             }
  120.            }
  121.         }
  122.                fprintf(k,"%d %s",counter2,red);
  123.                //printf("%d ", counter2);
  124.                counter2=0;
  125.     }
  126.     fclose(f);
  127.     fclose (k);
  128.     return 0;
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement