一道定义运算题目

来源:百度知道 编辑:UC知道 时间:2024/06/08 16:03:07
对任意两个正整数m,n,定义某种运算(用○×表示运算符号):当m,n都是正偶数或都是正奇数时,m○×n=m+n;当m,n-奇-偶时,则m○×n=mn,则在上述定义下,集合M={(m,n)| m○×n=36}中的元素个数为____.
已经知道答案是41了。需要详细解题步骤!!

给你写一段C++代码:
#include<iostream>

using namespace std;

int main()
{
int sum=0;
int count=0;
for (int i=1;i<37;i++)
{
for (int j=1;j<37;j++)
{
sum=((i+j)%2==0)?(i+j):(i*j);
if (sum==36)
{
count++;
cout<<i<<'\t'<<j<<endl;
}
}
}
cout<<count<<endl;
}下面是运行结果:
1 35
1 36
2 34
3 12
3 33
4 9
4 32
5 31
6 30
7 29
8 28
9 4
9 27
10 26
11 25
12 3
12 24
13 23
14 22
15 21
16 20
17 19
18 18
19 17
20 16
21 15
22 14
23 13
24 12
25 11
26 10
27 9
28 8
29 7
30 6
31 5
32 4
33 3
34 2
35 1
36 1
总数为:41