Skip to content

Instantly share code, notes, and snippets.

@appleios
Created June 14, 2015 08:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save appleios/29b2231bafce1afc2fdf to your computer and use it in GitHub Desktop.
Save appleios/29b2231bafce1afc2fdf to your computer and use it in GitHub Desktop.
task about family tv
#include <stdio.h>
#include <string.h>
#include <math.h>
int main()
{
int a,d,m,o,c,f,x;
printf("A D M O C | F\n");
for(x=0; x<32; x++){
a = x & 16;
d = x & 8;
m = x & 4;
o = x & 2;
c = x & 1;
f = (!o || m)&&(c || d)&&(m && !a || !m && a)&&(a&&c || !a && !c)&&(!d || c&&o);
printf("%d %d %d %d %d | %d\n",a>0,d>0,m>0,o>0,c>0,f);
}
return 0; // breakpoint
}
/*
Семья, состоящая из отца О, матери М, сына С и двух дочерей А и Д купила телевизор. Условились, что в первый вечер будут смотреть телевизор в таком порядке:
Когда отец О смотрит телевизор, то мать М делает то же.
Сын С и дочь Д, оба или один из них смотрят телевизор.
Из двух членов семьи - мать М и дочь А - смотрит телевизор одна и только одна.
Дочь А и сын С или оба смотрят, или оба не смотрят.
Если дочь Д смотрит передачу, то отец О и дочь С делают то же.
Кто из членов семьи в этот вечер смотрит передачу?
Ответ: A & C
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment