A friend ask me to help with his code. the input will be as following:
1st input -> number of loop
2nd input -> given number
3rd input -> number of rotation
example:
1
123045
3
The result is 045123
He told me that he can only get 45123 as the result. the 0 is missing. Is there any way to display it ?? i'm not very familiar with C or C++ though
here is his code. thx in advance
Code:#include <stdio.h> #include <stdlib.h> int main() { long int num,n,value, digitNum, ctr, NumX; int left, right; long b; scanf("%ld", &b); while (b != 0) { scanf("%d %d", &num, &n); value = num; NumX = 1; while (value!= 0) { NumX = NumX * 10; value = value / 10; } NumX = NumX / 10; ctr = 0; while (ctr != n) { left = num / 10; right = num % 10; num = right * NumX + left; ctr++; } printf("%d", num); printf("\n"); b--; } fflush(stdin);getch(); return 0; }



LinkBack URL
About LinkBacks


