Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #define nmax 31
  4. void popola(char s[]);
  5. void pali(char s[], int l);
  6. int i;
  7.  
  8. main(){
  9.  
  10. int n=nmax,lu;
  11. char str[n],risp;
  12.  
  13. do{
  14.  
  15. popola(str);
  16. lu=strlen(str);
  17. pali(str,lu);
  18.  
  19. printf("Se vuoi rieseguire il programma premi y altrimenti premi n\n");
  20. risp=getch();
  21. printf("\n\n\n\n");
  22. }while((risp=='Y')||(risp=='y'));
  23.  
  24. }
  25.  
  26. void popola(char s[]){
  27.  
  28. printf("Inserisci una parola\n");
  29. gets(s);
  30.  
  31. }
  32.  
  33. void pali(char s[], int l){
  34.  
  35. int t=0;
  36.  
  37. for(i=0;i<l/2;i++){
  38. if(s[i]!=s[(l-1)-i]){
  39. t=1;
  40. }
  41. }
  42.  
  43. if(t==1){
  44. printf("\nLa parola %s non e' palindroma\n\n",s);
  45. }else{
  46. printf("\nLa parola %s e' palindroma\n\n",s);
  47. }
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement