Свинг по-форумски? типа падрачить на Памелу?![]()
Одиноких мужчин на свинг парти не пускают. Кто из дам со мной за компанию?Originally Posted by Malishka
Ладно, Малышка, ты не захотела разобраться. Я уже нашел ошибку. Только почему-то функция rand мне выдает постоянно случайные числа... но почему-то одни и те же:( Я уже занимаюсь любовью с этим 2 часа
//program guesses a number from 1 to 100
//program guesses a number from 1 to 100
#include<iostream>
using std::cout;
using std::cin;
char isTooLow;
#include <cstdlib>
using std::rand;
using std::srand;
int Player(int, int);
int main()
{
int RandomNumbers[11];//0-9 locations of array will represent 10 random numbers.
//The number on 10th place will be the number of current try.
double average=0;
int i;
for (i=0;i<10;i++)
{
//cout << " "<< RandomNumbers[i] << " "<<i;
RandomNumbers[i] = rand() % 100 + 1;
//cout << " "<< RandomNumbers[i] << " "<<i;
//get 10 random numbers into the array
average = average + Player(RandomNumbers[i], i+1);//This function sums number of average tries by user
}
cout<<"The average number of tries is " << average/10.0;
cin>> average;
return 0;
}
int Player(int GetNumber, int i)
{
int guess;
int count=0;//number of times it took user to guess
//Display introduction
cout<< "Hello user! This is the time "<<i<< " you are guessing the number\n";
do
{
// Guessing rutine
count++;
cout << "What do you think the number is?\n";
cin >> guess;
if (guess == GetNumber)
{
cout << "you got it in "<<count<<" tries\n";
//if we too low, then we have to add 1 to the guess, else subtract 1.
}
else if(guess > GetNumber)
{
cout << "You are too high\n";
}
else
{
cout << "You are too low\n";
}
}
while (guess != GetNumber);
return count;
}
"In other words, stupid people are too stupid to know how stupid they are. "--если вам кажется что вы умны, то почитайте эту статью: http://blog.sfgate.com/nov05election...-thrive/?tsp=1--если же вам кажется что все вокруг идиоты, то так оно и есть.
на аву :angel:Originally Posted by peterburger
There are currently 1 users browsing this thread. (0 members and 1 guests)
|
|
Terms of Service | Privacy Policy |
|