Пример 2
Практикум по программированию №2
ВИУ5-51
Андрей Дёмин
Пример 1
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int a;
cout << "Please enter an integer: ";
cin >> a;
if (a >= 0)
{
cout << "Module of your integer is " << a << endl;
}
else
{
cout << "Module of your integer is " << -a << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
Пример 2
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
int x;
cout << "Please input X: ";
cin >> x;
int y;
cout << "Please input Y: ";
cin >> y;
if (x > 0)
{
if (y > 0)
{
cout << "The 1st quarter" << endl;
}
else
{
cout << "The 4th quarter" << endl;
}
}
else
{
if (y > 0)
{
cout << "The 2nd quarter" << endl;
}
else
{
cout << "The 3rd quarter" << endl;
}
}
system("PAUSE");
return EXIT_SUCCESS;
}
Не знайшли потрібну інформацію? Скористайтесь пошуком google:
|
|