Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning(disable:4996)
- #include <stdio.h>
- #include <stdlib.h>
- #include <conio.h>
- #include <math.h>
- /*
- struct Data {
- char nume[30];
- float nota;
- struct Data* next;//pointer catre urmatorul nod
- };
- typedef struct Data student;
- student* alloc() { // alocare memorie dinamica
- return (student*)malloc(sizeof(student));
- }
- //functie pt citirea listei
- void citire(student* start, int n) {
- start->next = NULL;
- student *nod = NULL;
- nod = start;//first va contine adresa de start a listei;
- printf("Introduceti datele studentilor:\n");
- for (int i = 0; i < n; i++) {
- nod->next = alloc();
- nod = nod->next;
- printf("\nStudent %d.\n", i + 1);
- printf("Introduceti numele: ");
- scanf("%s", nod->nume);
- // fgets((nod->nume), sizeof(nod->nume), stdin);
- printf("Introduceti nota: ");
- scanf_s("%f", &nod->nota);
- nod->next = NULL;
- }
- }
- void afisare(student* start) {
- student* nod = NULL;
- nod = start->next;
- int i = 0;
- printf("\nDate studenti: ");
- while (nod) { // NULL=ZERO // while(0) se inchide
- printf("\nStudent %d.\n",i+1);
- printf("Nume: %s.\n",nod->nume);
- printf("Nota: %.2f.\n", nod->nota);
- i++;
- nod=nod->next;
- }
- }
- void main() {
- int n = 0;
- printf("Introduceti nr de studenti: ");
- scanf_s("%d",&n);
- student* start = alloc();
- citire(start, n);
- afisare(start);
- _getch();
- }
- */
- typedef struct {
- int x, y;
- }PUNCT;
- PUNCT *alocare() {
- return ((PUNCT*)malloc(sizeof(PUNCT)));
- }
- void citire(PUNCT *P) {
- printf("\nx= ");
- scanf("%d", &P->x);
- printf("y= ");
- scanf("%d", &P->y);
- }
- double distanta(PUNCT *A, PUNCT *B) {
- return (sqrt(pow(B->x - A->x, 2) + pow(B->y - A->y, 2)));
- }
- void main() {
- PUNCT *A, *B, *C;
- A = alocare();
- B = alocare();
- C = alocare();
- printf("Pentru punctul A:");
- citire(A);
- printf("\nPentru punctul B:");
- citire(B);
- printf("\nPentru punctul C:");
- citire(C);
- double a, b, c;
- a = distanta(A, B);
- b = distanta(A, C);
- c = distanta(B, C);
- if (1) {
- #define A A->
- #define B B->
- #define C C->
- #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) ) )
- #define SPAM2 ( ( (A x != B x)&&(B x !=C x) ) && ( (A y != B y)&&(B y!= C y) ) )
- }
- if ( a == b && b == c && SPAM) {
- printf("Triunghiul este echilateral.");
- }
- else
- if (( a == b || a == c || b == c) && SPAM2) {
- printf("Triunghiul este isoscel.");
- printf("\na= %f", a);
- printf("\nb= %f", b);
- printf("\nc= %f", c);
- }
- else {
- //if ((A->x == A->y) && (B->x == B->y) && ( C->x == C->y) && (A->x == B->x) && (A->x == B->x))
- if ((A x == B x) && (B x == C x) && (A y == B y) && (B y == C y))
- printf("Este punct.");
- else
- if ((A x == B x) && (B x == C x))
- printf("Punctele sunt coliniare.");
- else
- if ((A y == B y) && (B y == C y))
- printf("Punctele sunt coliniare.");
- else {
- printf("Este alt tip de triunghi.");
- printf("\na= %f", a);
- printf("\nb= %f", b);
- printf("\nc= %f", c);
- }
- }
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement