Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Integer shift in c language
Integer shift in c language
When the number of shifts required is greater than the number of digits, your program is wrong.

For example, 12 5 (multiple revolutions are allowed).

I changed it for you, but I didn't change EOF:EOF:(scanf()= = EOF is an unattainable condition).

Specifies whether the input number has the maximum number of digits, otherwise it is better to read it directly with a string.

========

# include & ltstdio.h & gt

# include & ltstring.h & gt

int main(){

int x,n,I,j,L;

Character number [100];

While(scanf("%s %d ",& ampnumber & amp n)! =EOF)

{

l = strlen(num);

for(I = 0; I & ltn;; i++)

{

Number [99]= number [l-1];

for(j = L- 1; j & gt0; j-)num[j]= num[j- 1];

Number [0]= number [99];

}

printf("%s\n ",num); //This is output to you in the form of a string. You can convert it into int output and remove the 0 at the left end.

}

Returns 0;

}