Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- #include <iomanip>
- using namespace std;
- void PrintParity(int x)
- {
- string parity = (x % 2 == 0) ? "even" : "odd";
- cout << x << " is " << parity << endl;
- }
- string GetPositivity(int x)
- {
- if (x > 0)
- {
- return "positive";
- }
- else if (x < 0)
- {
- return "negative";
- }
- else
- {
- return "zero";
- }
- }
- void PrintPositivity(int x)
- {
- string positivity = GetPositivity(x);
- cout << x << " is " << positivity << endl;
- }
- int main()
- {
- PrintParity(6);
- PrintParity(7);
- PrintPositivity(-1);
- PrintPositivity(0);
- PrintPositivity(1);
- return 0;
- }
- Значение неинициализированной переменной неопределено!!!
- Zero overhead principle не плати за то, что не используешь
- int value; // мне все равно, что будет в переменной value
- int value = 0; // мне необходимо, чтобы в value был 0
- Инициализируйте переменные при объявлении
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement