Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- esercizio
- dato un vettore si vuole creare un altro vettore W che contiene il quadrato dell'elemento
- #include <iostream>
- #include <iomanip>
- #include <math.h>
- using namespace std;
- int main(){
- int n;
- cout<<"inserisci lunghezza n del vettore"<<endl;
- cin>>n;
- int *V=new int [n];
- for (int i=0;i<n;i++){
- cout<<"inserisci elementi ["<<i<<"]="<<endl;
- cin>>V[i];
- }//for
- int *W=new int [n];
- for (int i=0;i<n;i++){
- W[i]=V[i]*V[i];
- }//for
- for (int i=0;i<n;i++){// questo for mi serve a scorrere l array W
- cout<<W[i];
- }
- delete []V;
- delete [ ]W;
- }//main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement