Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. //
  2.  
  3. #include <iostream>
  4. #include <math.h>
  5. #include <string.h>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. void stampa_vettore_1(int n, const char V1[100])
  11. {
  12. for(int i=0; i<n; i++)
  13. {
  14. cout<<V1[i]<<" ";
  15.  
  16. }
  17.  
  18. }
  19.  
  20. /*
  21. void inverti_vettore_2(int n, const char V1[100])
  22. {
  23.  
  24. for(int i=n; i>=0; i--)
  25. {
  26. cout<<V1[i]<<" ";
  27.  
  28. }
  29.  
  30. }
  31. */
  32.  
  33. void inverti_vettore_2(int n,char V1[],char V2[])
  34. {
  35. int i, z;
  36. for( i=n-1,z=0; i>=0, z<n; i--, z++)
  37. {
  38. V2[z]==V1[i];
  39. }
  40.  
  41. }
  42.  
  43. int main ()
  44. {
  45. int n;
  46. char V1[n];
  47. char V2[n];
  48. cout<<"inserisci il numero di caratteri: ";
  49. cin>>n;
  50. cout<<endl;
  51.  
  52. for(int i=0; i<n; i++)
  53. {
  54. cout<<"inserisci il "<<i+1<<" valore: ";
  55. cin>>V1[i];
  56. cout<<endl;
  57. }
  58. cout<<" la stampa del vettore e': ";
  59. stampa_vettore_1(n, V1);
  60.  
  61.  
  62. inverti_vettore_2(n, V1, V2);
  63. cout<<"\nla stampa del vettore invertito e': "<<V2;
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement