Вот, нашел на одном из сайтов: #include <iostream>
#include <conio.h>
#include <cstdlib>
#include <ctime>
using namespace std;
int main (){
srand(time(0));
int n, one, two, co=0, ol, k=0, var, sum1=0, sum2=0;
bool kto=true;
cout << "Privet davaii sigraem v kosti.\nPobedit tot u kogo suma 3 broskov budet bolshe\n\n";
while (k<3)
{
cout << "\n1 - Brositj kubik\n2 - Vijti\nViberi variant: ";
cin >> var;
if (var==1)
for (int j=0; j<=1; j++)
one=1+(rand()%6);
two=1+(rand()%6);
cout << "\n";
if (kto) cout << "\tTvoi kubiki\n";
if (!kto) cout << "\tMoi kubiki\n";
for (int i=1; i<=5; i++)
if (i==1) n=1;
else if (i==2 && one==1) n=2;
else if (i==2 && one==3 || i==2 && one==2) n=3;
else if (i==2 && one==4 || i==2 && one==5 || i==2 && one==6) n=4;
else if (i==3 && one==3 || i==3 && one==1 || i==3 && one==5) n=5;
else if (i==3 && one==2 || i==3 && one==4) n=2;
else if (i==3 && one==6) n=4;
else if (i==4 && one==1) n=2;
else if (i==4 && one==3 || i==4 && one==2) n=6;
else if (i==4 && one==4 || i==4 && one==5 || i==4 && one==6) n=4;
else if (i==5) n=7;
switch (n){
case 1:
cout << (char)201 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)187;
break;
case 2:
cout << (char)186 << " " << (char)186;
case 3:
cout << (char)186 << " o " << (char)186;
case 4:
cout << (char)186 << " o o " << (char)186;
case 5:
case 6:
case 7:
cout << (char)200 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)188;
}
if (co%2==0) {
cout << "\t";
i--;
ol=one;
one=two;}
else {
cout << endl;
one=ol; }
co++;
if (kto){
sum1=sum1+one+two;
kto=false;
continue;
if(!kto){
sum2=sum2+one+two;
kto=true;
else if (var==2) return 0;
cout << "\n!!! Viberi variant 1 ili 2 !!!\n";
continue;}
k++;
cout << "\nTvoj rezultat = " << sum1 << endl << "Moj rezultat = " << sum2 << endl;
if (sum1>sum2)
cout << "\n\tTi pobedil ;)";
else cout << "\n\tTi proigral :(";
getch ();
begin
var a:=ArrRandom(100,-10,10);
a.Println;
Writeln(a.Where(x->x>0).Count,' положительных, ',
a.Where(x->x<0).Count,' отрицательных')
end.
Тестовое решение:
4 -6 0 8 2 -2 -1 -8 -6 8 -3 7 4 -7 -5 9 0 -3 -7 1 0 -4 6 3 8 -10 4 9 3 5 8 5 5 8 10 4 -8 3 8 8 -9 2 7 -8 -7 -5 2 -9 0 9 -7 7 -2 -6 7 -2 -1 7 -10 2 4 1 -1 0 10 3 -8 6 -6 2 6 7 -1 -4 -1 8 0 3 0 2 -2 2 -1 5 1 -9 -4 1 -9 1 -6 -5 3 -4 -7 1 -7 -3 -7 1
51 положительных, 42 отрицательных
Вот, нашел на одном из сайтов: #include <iostream>
#include <conio.h>
#include <cstdlib>
#include <ctime>
using namespace std;
int main (){
srand(time(0));
int n, one, two, co=0, ol, k=0, var, sum1=0, sum2=0;
bool kto=true;
cout << "Privet davaii sigraem v kosti.\nPobedit tot u kogo suma 3 broskov budet bolshe\n\n";
while (k<3)
{
cout << "\n1 - Brositj kubik\n2 - Vijti\nViberi variant: ";
cin >> var;
if (var==1)
{
for (int j=0; j<=1; j++)
{
one=1+(rand()%6);
two=1+(rand()%6);
cout << "\n";
if (kto) cout << "\tTvoi kubiki\n";
if (!kto) cout << "\tMoi kubiki\n";
cout << "\n";
for (int i=1; i<=5; i++)
{
if (i==1) n=1;
else if (i==2 && one==1) n=2;
else if (i==2 && one==3 || i==2 && one==2) n=3;
else if (i==2 && one==4 || i==2 && one==5 || i==2 && one==6) n=4;
else if (i==3 && one==3 || i==3 && one==1 || i==3 && one==5) n=5;
else if (i==3 && one==2 || i==3 && one==4) n=2;
else if (i==3 && one==6) n=4;
else if (i==4 && one==1) n=2;
else if (i==4 && one==3 || i==4 && one==2) n=6;
else if (i==4 && one==4 || i==4 && one==5 || i==4 && one==6) n=4;
else if (i==5) n=7;
switch (n){
case 1:
cout << (char)201 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)187;
break;
case 2:
cout << (char)186 << " " << (char)186;
break;
case 3:
cout << (char)186 << " o " << (char)186;
break;
case 4:
cout << (char)186 << " o o " << (char)186;
break;
case 5:
cout << (char)186 << " o " << (char)186;
break;
case 6:
cout << (char)186 << " o " << (char)186;
break;
case 7:
cout << (char)200 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)205 << (char)188;
break;
}
if (co%2==0) {
cout << "\t";
i--;
ol=one;
one=two;}
else {
cout << endl;
one=ol; }
co++;
}
if (kto){
sum1=sum1+one+two;
kto=false;
continue;
}
if(!kto){
sum2=sum2+one+two;
kto=true;
}
}
}
else if (var==2) return 0;
else {
cout << "\n!!! Viberi variant 1 ili 2 !!!\n";
continue;}
k++;
}
cout << "\nTvoj rezultat = " << sum1 << endl << "Moj rezultat = " << sum2 << endl;
if (sum1>sum2)
cout << "\n\tTi pobedil ;)";
else cout << "\n\tTi proigral :(";
getch ();
}