Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
// grayrat1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
#include "stdio.h"
#include "math.h"
#include "string.h"
void main(void)
{ char s[128],s1[130];
unsigned int i;
cin>>s;
for (i=0;i<=strlen(s);i++) s1[i]=s[i+1];
s1[strlen(s)-1]=s[0];
s1[strlen(s)]=0;
strcat(s1,"ay");
cout<<s1;
cin>>i;
}
// grayrat1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
#include "stdio.h"
#include "math.h"
#include "string.h"
#include "stdlib.h"
#include "time.h"
int pob=0,por=0,br=0,obr=0,v1br=0,v2br=0,p1br=0,p2br=0,
mas[100];
void setg(void)
{int k1,k2;
obr=0;
k1=int(rand()%6)+1;
k2=int(rand()%6)+1;
br++;obr++;
if ((k1+k2==7)||(k1+k2==11)) {pob++;v1br++;return;};
if ((k1+k2==2)||(k1+k2==3)||(k1+k2==12)) {por++;p1br++;return;};
for(;;) {
k1=int(rand()%6)+1;
k2=int(rand()%6)+1;
br++;obr++;
if ((k1+k2==11)) {pob++;v2br++;return;};
if ((k1+k2==7 )) {por++;p2br++;return;};
}
}
void main(void)
{ char s1;
int s=0;
time_t time1;
srand(time(&time1));
for (int i=0;i<12000;i++) {setg();mas[obr]++;}
for (i=1;i<100;i++) {s=s+i*mas[i];if (s>=int(0.9*br)) {cout<<"Нужно кинуть "<<i<<" раз, чтобы вероятность выигрыша была 90%";break;}}
cout<<endl<<"Всего поражений "<<por<<endl;
cout<<"Всего побед "<<pob<<endl;
cout<<endl<<"Выиграл с первого раза "<<v1br;
cout<<endl<<"Проиграл со второго раза "<<p1br;
cout<<endl<<"Проиграл не с первого раза "<<p2br;
cout<<endl<<"Выиграл не с первого раза "<<v2br;
cin>>s1;
}
Соседние файлы в папке ООП_ЭТМО