daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. /*enum Styles{
  5.     classic = 1,
  6.     pop,
  7.     rock,
  8.     rap,
  9.     newage,
  10.     electronic
  11. };
  12.  
  13. struct Triangle{
  14.  
  15.     struct Point{
  16.         double x;
  17.         double y;
  18.     };
  19.  
  20.     Point A;
  21.     Point B;
  22.     Point C;
  23.  
  24.     double Perimeter(){
  25.         double AB = sqrt(pow(B.x - A.x, 2) + pow(B.y - A.y, 2));
  26.         double BC = sqrt(pow(C.x - B.x, 2) + pow(C.y - B.y, 2));
  27.         double AC = sqrt(pow(C.x - A.x, 2) + pow(C.y - A.y, 2));
  28.         return AB + BC + AC;
  29.     }
  30. };*/
  31.  
  32. union Printer{
  33.     unsigned char value;
  34.     struct Status{
  35.         unsigned char isReady      : 1; // 0000000?
  36.         unsigned char isEmptyToner : 1; // 000000?0
  37.         unsigned char isDamaged    : 1; // 00000?00
  38.         unsigned char isEmptyPaper : 1; // 0000?000
  39.     } flags;
  40. };
  41.  
  42. void main() {
  43.     /*printf("%d\n", rock);
  44.     struct Triangle newTriangle;
  45.     newTriangle.A.x = 0; newTriangle.A.y = 0;
  46.     newTriangle.B.x = 3; newTriangle.B.y = 0;
  47.     newTriangle.C.x = 0; newTriangle.C.y = 4;
  48.     printf("%lf\n", newTriangle.Perimeter());*/
  49.     union Printer newPrinter;
  50.     scanf("%X", &newPrinter.value);
  51.     printf("Printer is ready: %s\n", newPrinter.flags.isReady ? "YES" : "NO");
  52.     printf("Toner is empty: %s\n", newPrinter.flags.isEmptyToner ? "YES" : "NO");
  53.     printf("Roller is damaged: %s\n", newPrinter.flags.isDamaged ? "YES" : "NO");
  54.     printf("Paper is empty: %s\n", newPrinter.flags.isEmptyPaper ? "YES" : "NO");
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top