Advertisement
Guest User

kkjk

a guest
Jan 27th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5. int num();
  6. void vl(char *punt,int m);
  7. bool b(char *punt, int m , int n);
  8.  
  9.  
  10. int num(){
  11.     int n;
  12.     cout<<"inserisci un numero ";
  13.     cin>>n;
  14.     return n;
  15. }
  16.  
  17. void vl(char *punt , int m){
  18.     cout<<"inserisci elementi del vettore ";
  19.     for (int i=0;i<m;i++){
  20.         cin>>punt+i;
  21.     }
  22. }
  23.  
  24. bool b(char *punt,int m,int n ){
  25.     bool q=false;
  26.     int k=(m/n);
  27.       for (int i=0; i<k;i++){
  28.         q=true;
  29.         for(int j=0;j<(n/2);j++){
  30.            
  31.             if((*punt+(i*n)+j)!=(*punt+i*n+(n-j))){
  32.                 q=false;
  33.                 break;
  34.             }
  35.         }
  36.         if(b)
  37.         i=k;
  38.       }
  39.       return q;
  40. }
  41. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  42.  
  43. int main(int argc, char** argv) {
  44. int n,m;
  45. char vett[100];
  46. char punt=vett[0];
  47. n=num();
  48. m=num();
  49. while(m%n!=0){
  50.  
  51.     cout<<"errore";
  52.     m=num();
  53. }  
  54.  
  55. vl(&punt , m);
  56.  
  57. cout<<" output  "<<b(&punt,m,n);
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement