Advertisement
LightProgrammer000

Estatísticas [String]

Dec 1st, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.02 KB | None | 0 0
  1. // Biblioteca
  2. #include <ctype.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5.  
  6. // Definição
  7. #define SIZE 1000000
  8.  
  9. int main()
  10. {
  11.     int a = 0;
  12.     int b = 0;
  13.     int c = 0;
  14.     int d = 0;
  15.     int e = 0;
  16.     int f = 0;
  17.     int g = 0;
  18.     int h = 0;
  19.     int i = 0;
  20.     int j = 0;
  21.     int k = 0;
  22.     int l = 0;
  23.     int m = 0;
  24.     char texto[] = " When in the Course of human events, it becomes necessary for one people to dissolve"
  25.                    " the political bands wich have connect them with another, and to assume among the powers of the earth,"
  26.                    " the separate and equal station to wich the Laws of Nature and of Natures's God them, a decente respect"
  27.                    " to the opinion of mankind requires that they should declare the causes wich impel them to the separation.";
  28.  
  29.     system("color E");
  30.  
  31.     while( texto[m] != '\0' )
  32.     {
  33.         // Verifica: LETRAS OU NÚMEROS
  34.         if( isalnum(texto[m]) )
  35.         {
  36.             a++;
  37.         }
  38.  
  39.         // Verifica: LETRAS MAIÚSCULA OU MINÚSCULA
  40.         if( isalpha(texto[m]) )
  41.         {
  42.             b++;
  43.         }
  44.  
  45.         // Verifica: ASCII
  46.         if( isascii(texto[m]) )
  47.         {
  48.             c++;
  49.         }
  50.  
  51.         // Verifica: CÓDIGO DE CONTROLE [0 a 31 e 127]
  52.         if( iscntrl(texto[m]) )
  53.         {
  54.             d++;
  55.         }
  56.  
  57.         // Verifica: CARACTERE [0 - 9]
  58.         if( isdigit(texto[m]) )
  59.         {
  60.             e++;
  61.         }
  62.  
  63.         // Verifica: CARACTERE EXCETO O ESPAÇO
  64.         if( isgraph(texto[m]) )
  65.         {
  66.             f++;
  67.         }
  68.  
  69.         // Verifica: LETRA MINUSCULA
  70.         if( islower(texto[m]) )
  71.         {
  72.             g++;
  73.         }
  74.  
  75.         // Verifica: QUALQUER CARACTERE, INCLUINDO ESPAÇO
  76.         if( isprint(texto[m]) )
  77.         {
  78.             h++;
  79.         }
  80.  
  81.         // Verifica: PONTUAÇÃO
  82.         if( ispunct(texto[m]) )
  83.         {
  84.             i++;
  85.         }
  86.  
  87.         // Verifica: ESPACO EM BRANCO, ESPACO, TAB E ENTER
  88.         if( isspace(texto[m]) )
  89.         {
  90.             j++;
  91.         }
  92.  
  93.         // Verifica: LETRA MAIÚSCULA
  94.         if( isupper(texto[m]) )
  95.         {
  96.             k++;
  97.         }
  98.  
  99.         // Verifica: HEXADECIMAL
  100.         if( isxdigit(texto[m]) )
  101.         {
  102.             l++;
  103.         }
  104.  
  105.         m++;
  106.     }
  107.  
  108.     printf("\n === ESTATISTICAS === \n");
  109.     printf("\n %s \n", texto);
  110.     printf("\n LETRAS E NUMEROS: %d", a);
  111.     printf("\n LETRAS MAIUSCULAS E MINUSCULAS: %d", b);
  112.     printf("\n ASCII: %d", c);
  113.     printf("\n CÓDIGO DE CONTROLE [0 a 31 e 127]: %d", d);
  114.     printf("\n CARACTERE [0-9]: %d", e);
  115.     printf("\n CARACTERE EXCETO O ESPACO: %d", f);
  116.     printf("\n LETRA MINUSCULA : %d", g);
  117.     printf("\n QUALQUER CARACTERE [INCLUINDO ESPACO] : %d", h);
  118.     printf("\n PONTUACAO: %d", i);
  119.     printf("\n CARACTERE DE ESPACO EM BRANCO, ESPACO, TAB, ENTER: %d", j);
  120.     printf("\n LETRA MAIUSCULA: %d", k);
  121.     printf("\n HEXADECIMAL: %d", l);
  122.     printf("\n CONTADOR: %d", m);
  123.     putchar('\n');
  124.  
  125.     return(0);
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement