Untitled
unknown
plain_text
a year ago
788 B
2
Indexable
Never
#include <iostream> using namespace std; int main() { int tam= 10; int elementos[tam]= {5,10,8,12,7,9,6,11,4,3}; for (int i=0; i<tam; i++){ cout<<elementos[i]<<"|"; } cout<<endl; int x=0; int index; int tempElements[tam]; cout<<"Ingrese un número x, entre 1 y 5"<<endl; cin>>x; if(!(x >= 1 && x <= 5)){ cout<<"El numero ingresado no es valido"<<endl; return 0; } for (int i=0; i<tam; i++){ int temp = elementos[i]; if ((i+x) >= tam){ index = (i+x) - tam; }else{ index = i+x; } tempElements[index] = temp; } for (int i=0; i<tam; i++){ cout<<tempElements[i]<<"|"; } return 0; }