Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.17 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4.  
  5. int a_erwtima(char str[])
  6. {
  7.     int i, sinolo;
  8.    
  9.     sinolo=1;
  10.     for(i=1; i<=100; i++)
  11.     {
  12.         if(str[i]==' ')
  13.         {
  14.             sinolo=sinolo+1;
  15.         }
  16.     }
  17.     printf("oi lexeis einai %d\n", sinolo);
  18.    
  19.     return 0;
  20. }
  21.  
  22.  
  23.  
  24.  
  25.  
  26. int b_erwthma(char str[])
  27. {
  28.     int T[26];
  29.     int i, sum, j, max;
  30.     char z, lmax;
  31.     char K[26];
  32.    
  33.     for(i=1; i<=26; i++)
  34.     {
  35.         T[i]=0;
  36.     }
  37.     i=1;
  38.     for(z='a'; z<='z'; z++)
  39.     {
  40.         K[i]=z;
  41.         i=i+1; 
  42.     }
  43.     sum=0;
  44.     for(i=1; i<=26; i++)
  45.     {
  46.         for(j=1; j<=100; j++)
  47.         {
  48.             if(str[j]==K[i])
  49.             {
  50.                 sum=sum+1;
  51.             }
  52.         }
  53.         T[i]=sum;
  54.         printf("%d",sum);
  55.         sum=0;
  56.     }
  57.    
  58.     max=T[1];
  59.     lmax=K[1];
  60.     for(i=2; i<=26; i++)
  61.     {
  62.         if(T[i]>max)
  63.         {
  64.             max=T[i];
  65.             lmax=K[i];
  66.         }
  67.     }
  68.     printf("o xaraktiras me tin megaliteri sixnotita einai o %c\n", lmax);
  69.     return 0;
  70. }
  71.  
  72. int c_erwthma(int end)
  73. {  
  74.  
  75. printf("termatismos? 1. NAI   2. OXI\n");
  76. scanf("%d", &end);
  77. return end;
  78. }  
  79.    
  80.    
  81.  
  82.  
  83. int main ()
  84. {
  85.     char str[100];
  86.     int epilogi, end;
  87.     do
  88.     {
  89.    
  90.     printf("dwse mia simbolosira\n");
  91.     gets(str);
  92.    
  93.             a_erwtima(str);
  94.             b_erwthma(str);
  95.             c_erwthma(end);
  96.     }while(end == 2);
  97.    
  98.     system("PAUSE");
  99.     return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement