注册 登录
编程论坛 C++教室

这个问题我始终弄不明白

a181625133 发布于 2018-01-01 18:03, 1597 次点击
#include <iostream>
using namespace std;

int a,b;

   int main()
{
    cin >>a,b;
    if (a%2==0,b%2==0)(a%2==1,b%2==1),
        cout <<"yes"<<endl;
    else
        cout<<"no"<<endl;
    return 0;
}
我其实想要弄一个a,b是否同奇偶的,可就是不行,请求帮助!
4 回复
#2
rjsp2018-01-02 08:18
程序代码:
#include <iostream>
using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if( (a%2==0 && b%2==0) || (a%2==1 && b%2==1) )
        cout << "yes" << endl;
    else
        cout << "no" << endl;
    return 0;
}

程序代码:
#include <iostream>
using namespace std;

int main( void )
{
    int a, b;
    cin >> a >> b;
    cout << (a%2==b%2?"yes":"no") << endl;
}



#3
a1816251332018-01-05 23:03
谢谢
#4
stop12042018-01-06 07:42
哪来的内容 搞得这么复杂
#5
yangfrancis2018-01-09 11:42
if(a%2!=b%2)
1