Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <fstream>
- #include <iostream>
- #include <ctime>
- #include <cmath>
- using namespace std;
- int proizvedenie(int npol, int* xp, int* yp, int* zp)
- {
- int c = 0;
- int tmp[3];
- cout << *xp << endl;
- tmp[0] = xp[1] * yp[2] - xp[2] * yp[1];
- tmp[1] = xp[0] * yp[2] - xp[2] * yp[0];
- tmp[2] = xp[0] * yp[1] - xp[1] * yp[0];
- c = tmp[0] * zp[0] - tmp[1] * zp[1] + tmp[3] * zp[3];
- return c;
- }
- const int n = 3;
- DWORD WINAPI run(LPVOID arg) {
- char * iFile = (char*)(static_cast<char**>(arg))[0];
- char * oFile = (char*)(static_cast<char**>(arg))[1];
- ifstream fin(iFile);
- ofstream fout(oFile);
- int* x = new int[n];
- int* y = new int[n];
- int* z = new int[n];
- for (int i = 0; i < n; ++i)
- {
- fin >> x[i];
- }
- for (int i = 0; i < n; ++i)
- {
- fin >> y[i];
- }
- for (int i = 0; i < n; ++i)
- {
- fin >> z[i];
- }
- try {
- fout << proizvedenie(n, x, y, z);
- cout << proizvedenie(n, x, y, z) << endl;
- }
- catch (...) {
- fout << "Ошибка в данных";
- }
- return 0;
- }
- int main()
- {
- int a = 0;
- char* iFile = "input.txt";
- char* oFile = "output.txt";
- char* params[] = { iFile, oFile };
- long timeBegin = clock();
- setlocale(LC_ALL, "Russian");
- HANDLE hHandle = CreateThread(NULL, 0, run, static_cast<void*>(params), 0, 0);
- if (hHandle == NULL)
- return GetLastError();
- WaitForSingleObject(hHandle, INFINITE);
- long time = clock() - timeBegin;
- CloseHandle(hHandle);
- cout << (double)time / CLOCKS_PER_SEC << " секунд" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement