12-11-2013, 06:16
|
מנהל פורומי "תכנות ובניית אתרים" ו"חומרה ורשתות"
|
|
חבר מתאריך: 25.10.01
הודעות: 42,775
|
|
אלה בדיוק התנאים שאתה צריך... אני לא מבין מה הבעייה...
קוד:
#include <iostream>
using namespace std;
int main ()
{
int a = 18;
cout << "The number " << a << " is ";
if (a % 2 == 0)
cout << "divisible";
else
cout << "not divisible";
cout << " by 2, and is ";
if (a % 5 == 0)
cout << "divisible";
else
cout << "not divisible";
cout << " by 5." << endl;
return 0;
}
או אפילו יותר פשוט:
קוד:
#include <iostream>
using namespace std;
int main ()
{
int a = 18;
cout << "The number " << a << " is ";
if (a % 2 != 0)
cout << "not ";
cout << "divisiable by 2, and is ";
if (a % 5 != 0)
cout << "not ";
cout << "divisiable by 5." << endl;
return 0;
}
|