|
|
|
|
для: Predgornoe
(08.01.2015 в 16:11)
|
| #include <iostream>
#include <string>
#include <ctime>
using namespace std;
void main()
{
srand(time(NULL));
int x[100], y[100];
for (int i = 0; i < 100; i++)
{
x[i] = -149 + rand() % 300;
}
for (int i = 0; i < 100; i++)
{
y[i] = -149 + rand() % 300;
}
int coun[5] = { 0, 0, 0, 0,0 };
//for (int i = 0; i < 100; i++)
//{
for (int j = 0; j < 100; j++)
{
if (x[j] == 0 || y[j] == 0) coun[4]++;
if (x[j]>0 && y[j]>0) coun[0]++;
if (x[j]<0 && y[j]>0) coun[1]++;
if (x[j] < 0 && y[j] < 0) coun[2]++;
if (x[j]>0 && y[j]<0) coun[3]++;
}
//}
cout << "first quarter: " << coun[0] << endl;
cout << "second quarter: " << coun[1] << endl;
cout << "third quarter: " << coun[2] << endl;
cout << "fourth quarter: " << coun[3] << endl;
if (coun[4] > 1)
{cout << "there are " << coun[4] << " dots with 0 coordinates.";}
else if (coun[4] ==1)
{cout << "there is " << coun[4] << " dots with 0 coordinates.";}
cin.get();
} |
| |
|
|