1. 程式人生 > >Day 3: Intro to Conditional Statements

Day 3: Intro to Conditional Statements

題目說明:


示例程式碼:

// day03_ConditionalStatements.cpp: 定義控制檯應用程式的入口點。
//
//if else 條件語句簡單使用
//

#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace std;

//by zhaocl
void ConditionalStatements( int N )
{
    if( N == 1 )
    {
        cout << "Weird" << endl;
    }
    else if( 2 <= N && N <= 5 && N % 2 == 0 )
    {
        cout << "Not Weird" << endl;
    }
    else if( 6 <= N && N <= 20 && N % 2 == 0 )
    {
        cout << "Weird" << endl;
    }
    else if( N > 20 && N % 2 == 0 )
    {
        cout << "Not Weird" << endl;
    }
    else
    {
        cout << "Weird" << endl;
    }
}

//by pallavi1292
void	ConditionalStatementsGood( int N )
{
    if( N % 2 == 1 || ( N >= 6 && N <= 20 ) )
        cout << "Weird" << endl;
    else
        cout << "Not Weird" << endl;
}

int main()
{
    int N;
    cin >> N;
    ConditionalStatements( N );
    system( "pause" );
    return 0;
}