123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <windows.h>
- #define OUTPUTFILE "D:\\Bolshakov41p\\Processes\\Files\\Output.txt"
- int main(int argc, char* argv[])
- {
- system("chcp 1251>nul");
- HANDLE OutputFile = CreateFileA(OUTPUTFILE,
- GENERIC_WRITE,
- 0,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- NULL);
- double a = atof(argv[0]);
- double b = atof(argv[1]);
- double c = atof(argv[2]);
- DWORD numBytesRead;
- double D;
- double x1;
- double x2;
- char output[100];
- int countRoots;
- if (a == 0)
- {
- sprintf(output, "Íĺ ęâŕäđŕňíîĺ óđŕâíĺíčĺ");
- WriteFile(OutputFile, output, strlen(output), &numBytesRead, NULL);
- }
- else
- {
- D = pow(b, 2) - 4 * a * c;
- }
- if (D < 0)
- {
- printf("Óđŕâíĺíčĺ íĺ čěĺĺň đĺřĺíč˙");
- sprintf(output, "Óđŕâíĺíčĺ íĺ čěĺĺň đĺřĺíč˙");
- WriteFile(OutputFile, output, strlen(output), &numBytesRead, NULL);
- countRoots = 0;
- }
- else if (D == 0)
- {
- x1 = (-b) / (2 * a);
- printf("Äčńęđčěěčíŕíň: %.2lf\n", D);
- printf("x1 = %.2lf", x1);
- sprintf(output, "Äčńęđčěěčíŕíň: %.2lf\n", D);
- WriteFile(OutputFile, output, strlen(output), &numBytesRead, NULL);
- sprintf(output, "x1 = %.2lf", x1);
- WriteFile(OutputFile, output, strlen(output), &numBytesRead, NULL);
- countRoots = 1;
- }
- else
- {
- x1 = (-b + sqrt(D)) / (2 * a);
- x2 = (-b - sqrt(D)) / (2 * a);
- printf("Äčńęđčěěčíŕíň: %.2lf\n", D);
- printf("x1 = %.2lf, x2 = %.2lf\n", x1, x2);
- sprintf(output, "Äčńęđčěěčíŕíň: %.2lf\n", D);
- WriteFile(OutputFile, output, strlen(output), &numBytesRead, NULL);
- sprintf(output, "x1 = %.2lf, x2 = %.2lf\n", x1, x2);
- WriteFile(OutputFile, output, strlen(output), &numBytesRead, NULL);
- countRoots = 2;
- }
- CloseHandle(OutputFile);
- return countRoots;
- }
|