Advertisement
Guest User

Untitled

a guest
Dec 11th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5. /* Deixa a string minuscula */
  6. char *min(char *str) {
  7.     int i;
  8.     for(i = 0; i < strlen(str); i++) {
  9.         str[i] = tolower(str[i]);
  10.     }
  11.     return str;
  12. }
  13.  
  14. int main(void) {
  15.     int qtd_pessoa, qtd_total=0;
  16.     char continuar[20];
  17.     float valor = 0;
  18.     scanf("%d", &qtd_pessoa);
  19.     valor += (qtd_pessoa+1)*14;
  20.     qtd_total += qtd_pessoa+1;
  21.     scanf(" %[^\n]s", continuar);
  22.     strcpy(continuar, min(continuar));
  23.     while(strcmp(continuar, "sair") != 0) {
  24.         scanf("%d", &qtd_pessoa);
  25.         scanf(" %[^\n]s", continuar);
  26.         valor += (qtd_pessoa+1)*14;
  27.         qtd_total += qtd_pessoa+1;
  28.         strcpy(continuar, min(continuar));
  29.     }
  30.     printf("%d\n%.2f\n", qtd_total, valor);
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement