不会
假设有: m > n >0&&m%n != 0则 n / m = 0, n % m= n;#include <iostream>
#include <array>
int main(int argc, char const *argv[])
{
std::array<int, 10> arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
std::array<int, 10> arr1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 11};
for (int i : arr)
{
for (int j : arr1)
{
if ((j != i) && (j < i))
{
std::cout << j << "/ " << i << " = " << j / i << " ";
std::cout << j << " % " << i << " = " << j % i << std::endl;
}
}
}
return 0;
}
-----------------------------------------------------------------------
Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。
尝试新的跨平台 PowerShell https://aka.ms/pscore6
PS E:\Users\admin\Documents\VScode> & 'c:\Users\admin\.vscode\extensions\ms-vscode.cpptools-0.26.1\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-dil1psuq.zyj' '--stdout=Microsoft-MIEngine-Out-4phhfec2.d3q' '--stderr=Microsoft-MIEngine-Error-l3e00pgz.mls' '--pid=Microsoft-MIEngine-Pid-garl0zf3.kjl' '--dbgExe=D:\MinGW\bin\gdb.exe' '--interpreter=mi'
1/ 2 = 0 1 % 2 = 1
1/ 3 = 0 1 % 3 = 1
2/ 3 = 0 2 % 3 = 2
1/ 4 = 0 1 % 4 = 1
2/ 4 = 0 2 % 4 = 2
3/ 4 = 0 3 % 4 = 3
1/ 5 = 0 1 % 5 = 1
2/ 5 = 0 2 % 5 = 2
3/ 5 = 0 3 % 5 = 3
4/ 5 = 0 4 % 5 = 4
1/ 6 = 0 1 % 6 = 1
2/ 6 = 0 2 % 6 = 2
3/ 6 = 0 3 % 6 = 3
4/ 6 = 0 4 % 6 = 4
5/ 6 = 0 5 % 6 = 5
1/ 7 = 0 1 % 7 = 1
2/ 7 = 0 2 % 7 = 2
3/ 7 = 0 3 % 7 = 3
4/ 7 = 0 4 % 7 = 4
5/ 7 = 0 5 % 7 = 5
6/ 7 = 0 6 % 7 = 6
1/ 8 = 0 1 % 8 = 1
2/ 8 = 0 2 % 8 = 2
3/ 8 = 0 3 % 8 = 3
4/ 8 = 0 4 % 8 = 4
5/ 8 = 0 5 % 8 = 5
6/ 8 = 0 6 % 8 = 6
7/ 8 = 0 7 % 8 = 7
1/ 9 = 0 1 % 9 = 1
2/ 9 = 0 2 % 9 = 2
3/ 9 = 0 3 % 9 = 3
4/ 9 = 0 4 % 9 = 4
5/ 9 = 0 5 % 9 = 5
6/ 9 = 0 6 % 9 = 6
7/ 9 = 0 7 % 9 = 7
8/ 9 = 0 8 % 9 = 8
PS E:\Users\admin\Documents\VScode> |