【发布时间】:2026-01-04 22:45:01
【问题描述】:
#include <iostream>
using namespace std;
int main()
{
// Here I seperate my number because at first I have to seperate and then I have to change the first digit and last digit.
int numri, shifrat, i = 0, a, shuma = 0, m, d;
cout << "Jep nje numer \n";
cin >> numri;
m = numri;
while (numri != 0) {
i++;
numri = numri / 10;
}
d = pow(10, i - 1);
numri = m;
while (numri != 0) {
shifrat = numri / d;
cout << shifrat << " ";
numri = numri % d;
d = d / 10;
}
//Now after that I have to change the last digit and first digit. Please help me.
//But I'm not allowed to use functions or swap only integers and loops or conditions.
cin.get();
}
有人可以帮帮我吗?
【问题讨论】:
-
你知道如何在纸上做吗?如果你有一个带有数字
xy和一个数字z的数字,你需要什么数学运算才能得到数字xyz? -
这就是我需要知道的。你能解释一下吗?
-
@Hana 如果创建的数字的值大于最大整数会怎样?例如 1000123039,因此数字是 9000123031?结果不适合 32 位整数。谁分配给你的没有考虑溢出?
标签: c++ visual-c++ c++17