Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ТирГотовыйскомментамиитестом.cpp: определяет точку входа для консольного приложения.
- //
- // Test.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <ctime>
- #include <cmath>
- #define LINE " __________________________________________________"
- #define LINE1 " -------------------------------------------------- "
- using namespace std;
- int main()
- {
- float *arrX, *arrY, *rad, kol_vis;
- srand(time(NULL));
- float X = 0;
- float Y = 0;
- int A;
- int R, R2;
- cout << "Razmer misheni: " << endl;
- cin >> A;
- R = 4 * A;
- R2 = R*R;
- float pramaya = sqrt(R2);
- /* int kol_tochek;
- cout << "Kollichestvo vistrelov : " << endl;
- cin >> kol_tochek;*/
- const int n = 10;
- int i;
- int flag = 0;
- int k;
- cout << "Vvedite kol-vo tochek iz kryga" << endl;
- cin >> k;
- float *arrayX = new float[k];
- float *arrayY = new float[k];
- float *arrayRad = new float[k];
- int *arrayRez = new int[k];
- int countX = 0;
- int countY = 0;
- int countRad = 0;
- int countRez = 0;
- do {
- X = (double)rand() / RAND_MAX * 2 * R - R;
- Y = (double)rand() / RAND_MAX * 2 * R - R;
- //X = (rand() % 100)/ (rand() % 3+1);
- // Y = (rand() % 100)/ (rand() % 3 + 1);
- //X = (rand() % 3 + 1)*-1;
- //Y = (rand() % 3 + 1)*-1;
- if ((X*X + Y*Y <= R*R)) {
- cout << X << " " << Y << endl;
- //arrayX[1] = -3;
- //arrayY[1] = -2;
- arrayX[countX] = X;
- countX++;
- arrayY[countY] = Y;
- countY++;
- arrayRad[countRad] = sqrt(pow(X, 2) + pow(Y, 2));
- countRad++;
- // break;
- if ((X*X + Y*Y <= R*R) && (Y >= -X - pramaya))
- {
- arrayRez[countRez] = 1;
- countRez++;
- cout << "Yes " << endl;
- }
- else
- {
- arrayRez[countRez] = 0;
- countRez++;
- cout << "No " << endl;
- }
- flag++;
- }
- } while (flag<k);
- cout << endl;
- for (int count = 0; count < k; count++)
- //cout << arrayX[count] << " " << arrayY[count] << endl;
- cout << arrayRez[count] << endl;
- cout << " Tablitcya rezyltatov " << endl;
- cout << " ___________________________________________________________" << endl;
- cout << "|" << " Nomer " << "|" << " X " << "|" << " Y " << "|" << " R " << "|" << " Rezultal " << "|" << endl;
- for (int count = 0; count < k; count++)
- {
- if (arrayRez[count] == 1)
- {
- cout << " -----------------------------------------------------------";
- printf("\n| %4d | %6.2f | %6.2f | %6.2f | Norma |\n", count + 1, arrayX[count], arrayY[count], arrayRad[count]);
- // cout << "| Norma |";
- // printf("Hi %с %d %s", 'с', 10, "there!");
- // cout << count<<" " << arrayRad[count]<<" "<<arrayX[count] << " " << arrayY[count] << " Norma" << endl;
- }
- if (arrayRez[count] == 0)
- {
- cout << " -----------------------------------------------------------";
- printf("\n| %4d | %6.2f | %6.2f | %6.2f | Brak |\n", count + 1, arrayX[count], arrayY[count], arrayRad[count]);
- }
- //cout << count <<" " << arrayX[count] << " " << arrayY[count] << " Brak" << endl;
- }
- cout << " -----------------------------------------------------------" << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement