功能
DESCRIPTION:determine the number is odd or even
用到的觀念
CODE
/*PROGRAMMER :楊翔斌*/
/*DATE :2009-10-08*/
/*FILENAME :HW01A002.cpp*/
/*DESCRIPTION:determine the number is odd or even*/
#include<iostream>//標頭檔
#include<iomanip>
using namespace std;//Indicates where header file is located
using std::getline;
using std::boolalpha;
using std::setw;
using std::fixed;
using std::setprecision;
#include<cstdlib>
using std::rand;
using std::srand;
#include<ctime>
using std::time;
int main()
{
cout<<"enter a positive number and it'll determine it is odd or even:";//tell
you to enter the number
int d;//宣告變數
cin>>d;//輸入存到d
if(d%2==0)//判斷d除以2的餘數是0
cout<<d<<" is an even number\n ";//tell you the number is even
else if(d%2!=0)//判斷d除以2的餘數不是0
cout<<d<<" is an odd number\n ";//tell you the number is odd
system("pause");//停止
return 0;//程式結束
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.7.59