Advertisement
Guest User

I want to die

a guest
Jul 12th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.29 KB | None | 0 0
  1. /* SCRIVERE UN PROGRAMMA IN C CHE DATA IN INPUT UNA STRINGA NE RESTITUISCA IN OUTPUT LA STRINGA AL CONTRARIO. SE LA STRINGA OTTENUTA E' UGUALE ALL'INIZIALE CONFERMARLO NELLA STAMPA A VIDEO
  2. */
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6.  
  7. int main() {
  8.             int lunghezza, i ,j;
  9.             char stringa[20];
  10.             char stringaf[20];
  11.            
  12.             printf("Digitare la stringa della quale si vuole ottenere la scrittura speculare: ");
  13.             scanf("%s", &stringa);
  14.            
  15.             lunghezza=strlen(stringa);
  16.            
  17.             strcpy(stringaf, stringa);
  18.            
  19.             for(i=0; i<=lunghezza; i++){ printf("%d", i);
  20.                                        j=lunghezza;
  21.                                        stringa[i]=stringa[j];
  22.                                        strcpy(stringaf, stringa);
  23.                                        lunghezza--;
  24.                                        }
  25.            
  26.             if(stringaf==stringa) printf("Abbiamo ottenuto la stringa: %s. Tale stringa e' palindroma.\n\n", stringaf);                  
  27.             else printf("Abbiamo ottenuto la stringa: %s . Tale stringa non e' palindroma.\n\n", stringaf);
  28.            
  29.             system("pause");
  30.             return 0;
  31.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement