Advertisement
frentzy

asd

Dec 13th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. #pragma warning(disable:4996)
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5. #include <math.h>
  6. /*
  7. struct Data {
  8. char nume[30];
  9. float nota;
  10. struct Data* next;//pointer catre urmatorul nod
  11. };
  12.  
  13. typedef struct Data student;
  14.  
  15. student* alloc() { // alocare memorie dinamica
  16. return (student*)malloc(sizeof(student));
  17. }
  18.  
  19. //functie pt citirea listei
  20. void citire(student* start, int n) {
  21. start->next = NULL;
  22. student *nod = NULL;
  23. nod = start;//first va contine adresa de start a listei;
  24. printf("Introduceti datele studentilor:\n");
  25. for (int i = 0; i < n; i++) {
  26. nod->next = alloc();
  27. nod = nod->next;
  28. printf("\nStudent %d.\n", i + 1);
  29. printf("Introduceti numele: ");
  30. scanf("%s", nod->nume);
  31. // fgets((nod->nume), sizeof(nod->nume), stdin);
  32. printf("Introduceti nota: ");
  33. scanf_s("%f", &nod->nota);
  34. nod->next = NULL;
  35. }
  36. }
  37.  
  38. void afisare(student* start) {
  39. student* nod = NULL;
  40. nod = start->next;
  41. int i = 0;
  42. printf("\nDate studenti: ");
  43. while (nod) { // NULL=ZERO // while(0) se inchide
  44. printf("\nStudent %d.\n",i+1);
  45. printf("Nume: %s.\n",nod->nume);
  46. printf("Nota: %.2f.\n", nod->nota);
  47. i++;
  48. nod=nod->next;
  49.  
  50. }
  51.  
  52.  
  53. }
  54.  
  55. void main() {
  56. int n = 0;
  57. printf("Introduceti nr de studenti: ");
  58. scanf_s("%d",&n);
  59.  
  60. student* start = alloc();
  61.  
  62. citire(start, n);
  63. afisare(start);
  64. _getch();
  65. }
  66.  
  67. */
  68.  
  69.  
  70. typedef struct {
  71. int x, y;
  72. }PUNCT;
  73.  
  74. PUNCT *alocare() {
  75. return ((PUNCT*)malloc(sizeof(PUNCT)));
  76. }
  77.  
  78. void citire(PUNCT *P) {
  79. printf("\nx= ");
  80. scanf("%d", &P->x);
  81. printf("y= ");
  82. scanf("%d", &P->y);
  83. }
  84.  
  85. double distanta(PUNCT *A, PUNCT *B) {
  86. return (sqrt(pow(B->x - A->x, 2) + pow(B->y - A->y, 2)));
  87. }
  88.  
  89. void main() {
  90. PUNCT *A, *B, *C;
  91.  
  92. A = alocare();
  93. B = alocare();
  94. C = alocare();
  95. printf("Pentru punctul A:");
  96. citire(A);
  97. printf("\nPentru punctul B:");
  98. citire(B);
  99. printf("\nPentru punctul C:");
  100. citire(C);
  101. double a, b, c;
  102. a = distanta(A, B);
  103. b = distanta(A, C);
  104. c = distanta(B, C);
  105. if (1) {
  106. #define A A->
  107. #define B B->
  108. #define C C->
  109. #define SPAM ( ( ( A x != B x )&&(A y != B y) ) || ( (A x != C x)&&(A y != C y) ) || ( (B x!= C x)&&(B y != C y) ) )
  110. #define SPAM2 ( ( (A x != B x)&&(B x !=C x) ) && ( (A y != B y)&&(B y!= C y) ) )
  111. }
  112. if ( a == b && b == c && SPAM) {
  113.  
  114. printf("Triunghiul este echilateral.");
  115. }
  116. else
  117. if (( a == b || a == c || b == c) && SPAM2) {
  118.  
  119. printf("Triunghiul este isoscel.");
  120. printf("\na= %f", a);
  121. printf("\nb= %f", b);
  122. printf("\nc= %f", c);
  123. }
  124. else {
  125.  
  126. //if ((A->x == A->y) && (B->x == B->y) && ( C->x == C->y) && (A->x == B->x) && (A->x == B->x))
  127. if ((A x == B x) && (B x == C x) && (A y == B y) && (B y == C y))
  128. printf("Este punct.");
  129. else
  130. if ((A x == B x) && (B x == C x))
  131. printf("Punctele sunt coliniare.");
  132. else
  133. if ((A y == B y) && (B y == C y))
  134. printf("Punctele sunt coliniare.");
  135. else {
  136. printf("Este alt tip de triunghi.");
  137. printf("\na= %f", a);
  138. printf("\nb= %f", b);
  139. printf("\nc= %f", c);
  140. }
  141. }
  142.  
  143. _getch();
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement