Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int rotacio_dreta(int x, int k) {
- int digits=0;
- for (int x2=x;x2>0;x2=x2/10) digits++;
- for (k; k>0; k--) {
- int lastdig=x%10;
- x=x/10;
- x=x+(lastdig*pow(10,(digits-1)));
- }
- return x;
- }
- int main() {
- int number,rotations;
- while(cin>>number>>rotations) cout<<rotacio_dreta(number,rotations)<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment