var k, l, m, n: integer; begin readln(k,l,m,n); if (k+l+m+n mod 2 = 0) then writeln('поля одного цвета') else writeln('поля разных цветов') end. |
4 answers
#include <cstdio> #include <iostream> using namespace std; #define var int #define begin { #define end ;} #define readln [](var&a, var&b, var&c, var&d){cin>>a>>b>>c>>d;} #define if if( #define mod )% #define then #define else ;else #define writeln puts var main() begin var k, l, m, n; begin readln(k,l,m,n); if (k+l+m+n mod 2 == 0) then writeln("поля одного цвета") else writeln("поля разных цветов") end end - oneor you can
readlnmacroreadlnexplain what[&]means before the parameters. - pavel - @pavel, lambda function with the capture of all by reference. Overworked. At first I wanted to do without parameters, but the commas prevented. - Qwertiy ♦
- oneCool! C ++ has grown up in my eyes :) - user207618
- one@pavel, and if the template function, and not a macro? - Qwertiy ♦
- one@Qwertiy
bool read() { return false; } template<typename... T> bool read(auto &a, T&... tail) { cin >> a; return cin.fail() || read(tail...); }bool read() { return false; } template<typename... T> bool read(auto &a, T&... tail) { cin >> a; return cin.fail() || read(tail...); }is it possible or easier? - pavel
|
int k, l, m, n; cin >> k >> l >> m >> n; cout << "поля "<< (k^l^m^n&1 ? "разных цветов":"одного цвета")<<endl; I like it better :)
- I was waiting for a similar option. Brevity - the sister of talent;) - AivanF.
|
In fact, it was possible to google functions from C ++ and examples of their writing. The code wouldn't change too much :)
int k, l, m, n; scanf("%d%d%d%d", &k, &l, &m, &n); if((k + l + m + n) % 2 == 0) printf("поля одного цвета"); else printf("поля разных цветов"); - 2Well, you rather have Pure C. - aryndin
|
#include <iostream> using namespace std; int main() { setlocale(LC_ALL, "Russian"); int k(0), l(0), m(0), n(0); cin >> k >> l >> m >> n; if ((k + l + m + n) % 2 == 0) { cout << "поля одного цвета" << endl; } else { cout << "поля разных цветов" << endl; } return 0; } |