Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <conio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <list>
- #include <bitset>
- #include <vector>
- using namespace std;
- const unsigned char MAX_CUPE = 255;
- static unsigned char m; // linii
- static unsigned char n; // coloane
- static unsigned char c; // cupe
- static unsigned char p[MAX_CUPE][2]; // pozitii cupe
- static unsigned long long g; // variabila ajutatoare
- // h - numarul de linii, w - numarul de coloane
- void f(char h, char w)
- {
- system("cls");
- c = 0;
- n =m = 12;
- int i, j,x=0,y=1;
- p[0][x] = 2; p[0][y] = 2;
- p[1][x] = 2; p[1][y] = 5;
- p[2][x] = 2; p[2][y] = 7;
- p[3][x] = 4; p[3][y] = 9;
- p[4][x] = 6; p[4][y] = 3;
- p[5][x] = 6; p[5][y] = 5;
- p[6][x] = 9; p[6][y] = 2;
- p[7][x] = 9; p[7][y] = 5;
- p[8][x] = 9; p[8][y] = 7;
- p[9][x] = 9; p[9][y] = 9;
- /*for (i = 1; i < n; i++) {
- for (j = 1; j < m; j++) {
- if (p[c][x] == i&&p[c][y] ==j) {
- cout << 'O';
- c++;
- }
- else
- cout << '.';
- }
- cout << endl;
- }*/
- for (i = 0; i < n; i++) {
- for (j = 0; j < m; j++) {
- if (j == 0 || i == 0)
- cout << '#';
- if (i > 0 && i < n - 1 && j >= 1 && j < m - 1) {
- if (p[c][x] == i&&p[c][y] == j) {
- cout << 'O';
- c++;
- }
- else
- cout << '.';
- }
- if (i == n - 1 || j == m - 1)
- cout << '#';
- }
- cout << endl;
- }
- }
- void main() {
- char h=0, w=0;
- f(h, w);
- getchar();
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////
- #include <iostream>
- #include <fstream>
- #include <conio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <list>
- #include <bitset>
- #include <vector>
- using namespace std;
- const unsigned char MAX_CUPE = 255;
- static unsigned char m; // linii
- static unsigned char n; // coloane
- static unsigned char c; // cupe
- static unsigned char p[MAX_CUPE][2]; // pozitii cupe
- static unsigned long long g; // variabila ajutatoare
- // h - numarul de linii, w - numarul de coloane
- void f(char h, char w)
- {
- int q, r;
- int x = 0, y = 1, i, j;
- unsigned int lovitura = 1, cupa1=1, cupa2=1;
- int pozx = 1, pozy = 1, pozx2 = 1, pozy2 = 1;
- unsigned char jucator = 1;
- char minge='*';
- c = 6;
- n = m = 15;
- p[1][x] = 2; p[1][y] = 2;
- p[2][x] = 2; p[2][y] = 5;
- p[3][x] = 2; p[3][y] = 7;
- p[4][x] = 4; p[4][y] = 9;
- p[5][x] = 6; p[5][y] = 3;
- p[6][x] = 6; p[6][y] = 5;
- p[7][x] = 9; p[7][y] = 2;
- p[8][x] = 9; p[8][y] = 5;
- p[9][x] = 9; p[9][y] = 7;
- p[10][x] = 9; p[10][y] = 9;
- p[11][x] = 10; p[11][y] = 8;
- p[12][x] = 12; p[12][y] = 13;
- p[13][x] = 14; p[13][y] = 2;
- p[14][x] = 14; p[14][y] = 14;
- while (jucator <= 2) {
- c = 1;
- for (i = 1; i < n; i++) {
- for (j = 1; j < m; j++) {
- if (i==1&&j==1) {
- cout << minge;
- }
- else if (p[c][x] == i&&p[c][y] == j) {
- cout << (int)c;
- c++;
- }
- else
- cout << '.';
- }
- cout << endl;
- }
- while (lovitura <= 200) {
- if (cupa1&&cupa2 <= c) {
- if (jucator == 1) {
- cout << "h=";
- cin >> q;
- cout << "w=";
- cin >> r;
- pozx += q; pozy += r;
- if (pozx < 1 || pozx>15 || pozy < 1 || pozy>15) {
- pozx -= q; pozy -= r;
- }
- cout << "A lovit jucatorul " << '1' << '.' << "Numar lovituri " << lovitura << '.';
- if (p[cupa1][x] == pozx&&p[cupa1][y] == pozy) {
- cout << "Cupa curenta:" << cupa1 << "<hit>" << '.';
- cupa1++;
- }
- else
- cout << "Cupa curenta:" << cupa1 << '.';
- cout << "Pozitie curenta:(" << pozx << ',' << pozy << ")." << endl;
- }
- else if (jucator == 2) {
- cout << "h=";
- cin >> q;
- cout << "w=";
- cin >> r;
- pozx2 += q; pozy2 += r;
- if (pozx2 < 1 || pozx2>15 || pozy2 < 1 || pozy2>15) {
- pozx2 -= q; pozy2 -= r;
- }
- cout << "A lovit jucatorul " << '2' << '.' << "Numar lovituri " << lovitura << '.';
- if (p[cupa2][x] == pozx2&&p[cupa2][y] == pozy2) {
- cout << "Cupa curenta:" << cupa2 << "<hit>" << '.';
- cupa2++;
- }
- else
- cout << "Cupa curenta:" << cupa2 << '.';
- cout << "Pozitie curenta:(" << pozx2 << ',' << pozy2 << ")." << endl;
- lovitura++;
- }
- jucator++;
- }
- }
- }
- }
- void main() {
- char h=0, w=0;
- f(h, w);
- getchar();
- }
- //////////////////////////////////////////////////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement