123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- #pragma once
- #include <stdio.h>
- #include <malloc.h>
- #include <math.h>
- #define SIZE 100
- #define LEN_ONE strlen(str1)
- #define LEN_TWO strlen(str2)
- #define SUMM a+b
- #define DIFF a-b
- #define POW a*b
- #define DEL a/b
- #define LANGUAGE "chcp 1251 > nul"
- #define LINESIGMENT(a)(a*a)
- double Summa(double, double);
- double Difference(double, double);
- double Pow(double, double);
- double Del(double, double);
- char* Unification(char* str1, char* str2);
- void Transformation();
- double p = 0;
- double s = 0;
- int Line(int x1, int x2, int y1, int y2, int x3, int y3) {
- if (x1 == x2 || y1 == y2 || x1 == x3 || x2 == x3 || y1 == y3 || y2 == y3) {
- printf("Êîîðäèíàòû âòîðîé òî÷êè äîëæíû áûòü áîëüøå èëè ìåíüøå ïåðâîé");
- return 1;
- }
- double d1;
- double d2;
- double d3;
- double pp;
- int x = (x2 - x1);
- int y = (y2 - y1);
- int z = (x3 - x2);
- int c = (y3 - y2);
- int g = (x1 - x3);
- int h = (y1 - y3);
- d1 = sqrt(LINESIGMENT(x) + LINESIGMENT(y));
- /*printf("%.2lf\n", d1);*/
- d2 = sqrt(LINESIGMENT(z) + LINESIGMENT(c));
- /*printf("%.2lf\n", d2);*/
- d3 = sqrt(LINESIGMENT(g) + LINESIGMENT(h));
- /*printf("%.2lf\n", d3);*/
- if (d1 < (d2 + d3) && d2 < (d1 + d3) && d3 < (d2 + d1)) {
- p = d1 + d2 + d3;
- pp = p / 2;
- s = sqrt(pp * (pp - d1) * (pp - d2) * (pp - d3));
- return 0;
- }
- else {
- return -1;
- }
- }
- void Triangle() {
- if (Line(2, 4, 1, 2, 3, 3) == -1) {
- printf("Òðåóãîëüíèêà íå ñóùåñòâóåò");
- }
- else {
- printf("%.2lf\n", p);
- printf("%.2lf\n", s);
- }
-
- }
- char* Unification(char* str1, char* str2) {
- char* result = malloc(LEN_ONE + LEN_TWO + 1);
- sprintf(result, "%s %s", str1, str2);
- return result;
- }
- double Summa(double a, double b) {
- return SUMM;
- }
- double Difference(double a, double b) {
- return DIFF;
- }
- double Pow(double a, double b) {
- return POW;
- }
- double Del(double a, double b) {
- return DEL;
- }
- void Transformation() {
- printf("Âûáåðèòå æåëàåìîå äåéñòâèå:\n1 - Êîíâåðòèðîâàòü ñòðîêó â ÷èñëî\n2 - Êîíâåðòèðîâàòü ÷èñëî â ñòðîêó\n");
- int number;
- scanf("%d", &number);
- if (number == 1) {
- printf("Ââåäèòå ñòðîêó: ");
- char* str = malloc(sizeof(char));
- scanf("%s", str);
- double arr;
- sscanf(str, "%lf", &arr);
- printf("×èñëî: %.2lf", arr);
- return 0;
- }
- else if (number == 2) {
- printf("Ââåäèòå ÷èñëî: ");
- double array;
- scanf("%lf", &array);
- char* str = malloc(sizeof(char));
- sprintf(str, "%.2lf", array);
- printf("%s", str);
- return 0;
- }
- else {
- printf("Òàêîé çàäà÷è íå ñóùåñòâóåò!");
- return 1;
- }
- printf("\n");
- }
|