Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
「10進右巡回シフト」と呼ばれる必要があります。たとえば、入力が8652出力の場合は になります2865。
8652
2865
文字列や文字列操作に変換せずに CPP でこの操作を行う方法はありますか? 算術演算、ループ、およびバイナリへの変換を使用するだけです。
number の桁数が厳密に 4 の場合、次のことができます。
int src = 1234; int dest = (src / 10) + (src % 10) * 1000;
ここで、末尾に を付けるsrcと3 桁になります。あなたはそれを処理する必要があります。0dest
src
0
dest
他の長さについては、コードを適切に調整する必要があります。