Guest User

Untitled

a guest
Aug 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main() {
  5.     char result[1000];
  6.     char entrada[100];
  7.     int marias = 0;
  8.     int i = 0;
  9.     for(i = 0; i < 20; i++) {
  10.         printf("Dame el nombre %i", i);
  11.         gets(entrada);
  12.         if(entrada[(unsigned)strlen(entrada) - 1] == 's' || entrada[(unsigned)strlen(entrada) - 1] == 'S') {
  13.             strncat(result, entrada, strlen(entrada));
  14.             strncat(result, " ", 1);
  15.         }
  16.        
  17.         if(strcmp(entrada, "maria") == 0)
  18.             marias++;
  19.     }
  20.     printf("Los nombres que terminan con s son: %s", result);
  21.     printf("El porcentaje de marias es: %d", (marias/20)*100);
  22.     return 0;
  23. }
Add Comment
Please, Sign In to add comment