Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4.  
  5. int palindroma (int);
  6. int contatore (int);
  7. int a;
  8. int i=0;
  9. int flag=1;
  10. int count_v=0;
  11. int count_c=0;
  12.  
  13. int palindroma (int i, int flag, char s[])
  14. {
  15.  
  16. while ((i<(strlen(s)/2)) && (flag==1))
  17. {
  18. if (s[i] != s[strlen(s)-i-1])
  19. {
  20. flag=0;
  21. }
  22. i++;
  23. }
  24. if (flag==1) {
  25. printf("La parola e' palindroma\n" );
  26. }
  27. else {
  28. printf("La parola non e' palindroma\n");
  29. }
  30.  
  31. }
  32. int contatore (char s [30], int count_v, int count_c, int a )
  33. {
  34. while (a<strlen(s))
  35. {
  36. if ((s[a]=='a' ) || (s[a] == 'e' ) || (s[a] == 'i') || (s[a] == 'o') || (s[a]== 'u'))
  37. count_v++;
  38. else
  39. count_c++;
  40. a++;
  41. }
  42. printf ("Il numero di vocali contenute nella parola e': %d\nIl numero di consonanti e': %d\n",count_v, count_c);
  43. return 0;
  44. }
  45.  
  46.  
  47. int main ()
  48. {
  49.  
  50. char s [30];
  51. printf ("Inserisci una parola: \n");
  52. scanf("%s", s);
  53. int y;
  54. y= palindroma (i, flag, s );
  55. int x;
  56. x= contatore (s, count_v, count_c, a);
  57.  
  58.  
  59. return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement