Batalha naval c++

Disponível somente no TrabalhosFeitos
  • Páginas : 4 (888 palavras )
  • Download(s) : 0
  • Publicado : 3 de abril de 2013
Ler documento completo
Amostra do texto
#include<stdlib.h>
#include<iostream>
#include<iomanip>

using namespace std;

int main (){
//variaveis
int tab[100], pos1, pos2, pos3;
int direcao;srand(time(NULL));

while(true){
for( int i=0; i<100; i++){
tab[i]= 0;
}

pos1 = rand()%100;
tab[pos1]= 1;if( pos1 == 0){
do{
pos2 = rand()%100;
}while(!((pos2 == pos1+ 1) || (pos2 == pos1+ 10) || (pos2 == pos1+ 11)));
} else if (pos1 == 9){do{
pos2 = rand()%100;
}while(!((pos2 == pos1- 1) || (pos2 == pos1+ 9) || (pos2 == pos1+ 10)));
} else if (pos1 == 90){
do{
pos2 =rand()%100;
}while(!((pos2 == pos1- 9) || (pos2 == pos1 - 10) || (pos2 == pos1+ 1)));
} else if (pos1 == 99){
do{
pos2 = rand()%100;}while(!((pos2 == pos1- 1) || (pos2 == pos1 - 10) || (pos2 == pos1- 11)));
} else if( pos1 > 1 && pos1 < 8){
do{
pos2 = rand()%100;
}while(!((pos2== pos1-1) || (pos2 == pos1+ 1) || (pos2 == pos1+ 9) || (pos2 == pos1+ 10) || (pos2 == pos1+ 11)));
} else if( pos1 == 1){
do{
pos2 = rand()%100;}while(!((pos2 == pos1-1) || (pos2 == pos1+ 1) || (pos2 == pos1+ 10) || (pos2 == pos1+ 11)));
} else if( pos1 == 8){
do{
pos2 = rand()%100;}while(!((pos2 == pos1-1) || (pos2 == pos1+ 1) || (pos2 == pos1+ 10) || (pos2 == pos1+ 9)));
} else if( pos1 == 10){
do{
pos2 = rand()%100;}while(!((pos2 == pos1+1) || (pos2 == pos1- 10) || (pos2 == pos1+ 10) || (pos2 == pos1+ 11)));
} else if( pos1 == 19){
do{
pos2 = rand()%100;...
tracking img