Guest User

?: demo and short scheme demo

a guest
Sep 10th, 2012
122
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdio>
  2.  
  3. //?: demo and short scheme demo
  4. int main() {
  5.   {
  6.     int n = 13423432;
  7.     while (n) {
  8.       printf(n & 1 ? "Zero\n" : "One\n");
  9.       n >>= 1;
  10.     }
  11.   }
  12.  
  13.   double x = 15;
  14.   (x < 10) ? printf("Less\n") : printf("More\n");
  15.  
  16.  
  17.   {
  18.     int n = 19;
  19.     n += (n % 2) ? 1 : 0; //Of course, we can use n & 1;
  20.   }
  21.  
  22.   {
  23.     int k = -10;
  24.  
  25.     (k > 0) || printf("Warning! k < 10\n");
  26.  
  27.     k && printf("k is not null!\n");
  28.   }
  29.  
  30.   return 0;
  31. }
RAW Paste Data