Răspuns :
#include <iostream>
using namespace std;
int main(){
int n,v[10]={0},ncif=0,i;
//Citire numar
cin >> n;
//Salvare cifre in vector, determinare numar de cifre
while(n){
v[++ncif] = n%10;
n=n/10;
}
//Afisare numar
cout << v[ncif];
for(i=1;i<ncif;i++) cout << v[i];
}
solutia fara vectori
#include<iostream>
using namespace std;
int main() {
int n, nn = 0, p = 1;
cin >> n;
while (n >= 9) {
nn = nn * 10 + n % 10;
n /= 10;
p *= 10;
}
nn = n % 10 * p + nn;
cout << nn;
return 0;
}
merge si cu o singura variabila, dar e tricky si nu vreau sa-ti bati capul! ;)
e mai usor de inteles asa