Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. enum PaperThings
  5. {
  6. Book,
  7. Magasine,
  8. NewsPaper,
  9. MetodichkaPoEVM,
  10. NoteBook
  11. };
  12.  
  13. struct Rectangle
  14. {
  15. double x0, y0, x1, y1, x2, y2, x3, y3;
  16. };
  17.  
  18. double getArea(struct Rectangle myRectangle) {
  19. return (sqrt(pow((myRectangle.x1 - myRectangle.x0), 2) +
  20. pow((myRectangle.y1 - myRectangle.y0),2))*sqrt(pow((myRectangle.x3 - myRectangle.x1), 2) +
  21. pow((myRectangle.y3 - myRectangle.y1), 2)));
  22. }
  23.  
  24. struct state_bits
  25. {
  26.  
  27. unsigned int reproduction : 1;
  28. unsigned int pause : 1;
  29. unsigned int record : 1;
  30. };
  31.  
  32. typedef union MP3Player {
  33. struct state_bits bits;
  34. unsigned int state;
  35. };
  36.  
  37. int main() {
  38. enum PaperThings a = NewsPaper;
  39. printf("%d\n", a);
  40. struct Rectangle square1 = { 0.0, 3.0, 4.0, 3.0, 0.0, 0.0, 4.0, 0.0 };
  41. printf("%f\n", getArea(square1));
  42. union MP3Player my_mp3;
  43. scanf_s("%hx", &my_mp3.state);
  44. if (my_mp3.bits.reproduction == 1) {
  45. printf("mp3 is reproducting\n");
  46. }
  47. else {
  48. printf("mp3 is not reproducting\n");
  49. }
  50. if (my_mp3.bits.pause == 1) {
  51. printf("mp3 is on pause\n");
  52. }
  53. else {
  54. printf("mp3 is out of pause\n");
  55. }
  56. if (my_mp3.bits.record == 1) {
  57. printf("mp3 is recording\n");
  58. }
  59. else {
  60. printf("mp3 is not recording\n");
  61. }
  62. int g;
  63. scanf_s("%i\n", &g);
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement