C++入门经典-例3.9-使用嵌套表达式判断一个数是否是3和5的整数倍

1:代码如下:

// 3.9.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<iostream>
using namespace std;
void main()
{
    int iInput;
    cout << "输入一个整数" << endl;
    cin >> iInput;    //从键盘中输入一个数
    (iInput%3==0)? 
        ((iInput%5==0) ? cout << "yes" : cout << "no" )
        : cout << "no";    
    cout << endl;
}
View Code

运行结果:

posted @ 2017-09-13 14:46  一串字符串  阅读(316)  评论(0编辑  收藏  举报