Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. struct complexs { // complex зарезервированное слово
  4. double real;
  5. double image;
  6. };
  7. complexs mascomplex[3] = {{ 1.5, 2.9 },{0.8, 5.1},{0, 0}}; // нет типа
  8. struct stock_info
  9. {
  10. char Name[30];
  11. char LetterGroup[3];
  12. int Group;
  13. float Stipendia;
  14. char Poyasnenie[20];
  15. };
  16. stock_info MasStud[5] = { {"Владислав Егоров", "N", 3147, 5, "Одногруппник"}, // нет типа
  17. {"Эрик Мулькаманов", "Э", 118, 2400, "Друг"},
  18. {"Вера Алексеева", " k", 104, 1621, "Подруга"},
  19. {"Роман Макотовчук", " k", 10, 1800, "Друг"},
  20. {"Евгений Смирнов", " l", 22107, 3880, "Друг"}
  21. };
  22. int main()
  23. {
  24. printf("\nComplex \n");
  25.  
  26. mascomplex[2].real = mascomplex[0].real + mascomplex[1].real;
  27. mascomplex[2].image = mascomplex[0].image + mascomplex[1].image;
  28. printf("Sum: %.1lf + i * %.1lf \n", mascomplex[2].real, mascomplex[2].image);
  29. mascomplex[2].real = mascomplex[0].real - mascomplex[1].real;
  30. mascomplex[2].image = mascomplex[0].image - mascomplex[1].image;
  31. printf("Dif: %.1lf + i * %.1lf \n", mascomplex[2].real, mascomplex[2].image);
  32. mascomplex[2].real = mascomplex[0].real * mascomplex[1].real - mascomplex[0].image * mascomplex[1].image;
  33. mascomplex[2].image = mascomplex[0].real * mascomplex[1].image + mascomplex[1].real *mascomplex[0].image;
  34. printf("Product: %.1lf + i * %.1lf \n", mascomplex[2].real, mascomplex[2].image);
  35. mascomplex[2].real = (mascomplex[0].real * mascomplex[1].real + mascomplex[0].image * mascomplex[1].image) / (mascomplex[1].real * mascomplex[1].real + mascomplex[1].image * mascomplex[1].image);
  36. mascomplex[2].real = mascomplex[0].real * mascomplex[1].image - mascomplex[0].real * mascomplex[1].image;
  37. printf("Quotient: %.3lf + i * %.3lf \n", mascomplex[2].real, mascomplex[2].image);
  38. for (int i = 0; i < 5; i++) {
  39. printf("Имя: %s \n", MasStud[i].Name);
  40. }
  41. for (int i = 0; i < 5; i++) {
  42. printf("Литер группы: %s \n", MasStud[i].LetterGroup);
  43. }
  44. for (int i = 0; i < 5; i++) {
  45. printf( "Группа: %s%d \n", MasStud[i].Group);
  46. }
  47. for (int i = 0; i < 5; i++) {
  48. printf("Стипендия: %d \n", MasStud[i].Stipendia);
  49. }
  50. for (int i = 0; i < 5; i++) {
  51. printf("Кто: %s \n", MasStud[i].Poyasnenie);
  52. }
  53. int A = 0xABC1B2E3;
  54. printf("%X \n", A);
  55. int *pA = &A;
  56. unsigned short B = *((short*)pA);
  57. unsigned short C = *((short*)pA+1);
  58. *((short*)pA) = C;
  59. *((short*)pA + 1) = B;
  60. printf("%X ", A);
  61. return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement