Форум С++

 

Ответить на сообщение

Вернуться к теме

Вы отвечаете на сообщение:

Автор: al_prix   (27.06.2015 в 17:49)
#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();
}


Ваше имя:

Пароль:

Цитировать

Используйте тэги для выделения текста:
Код: [code][/code]
Жирный: [b][/b]
Наклонный: [i][/i]
URL: [url][/url]

Сообщение:

Прикрепить: