Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <vector>
- #include <algorithm>
- int pkt[1000];
- int wiersz[1000];
- using namespace std;
- int main()
- {
- ifstream plik;
- int plansza[20][20];
- plik.open("plansza.txt");
- for (int i=0;i<20;i++)
- {
- for (int j=0;j<20;j++)
- plik >> plansza[i][j];
- }
- ifstream plik2;
- plik2.open("robot.txt");
- string ruchy[1000];
- for (int i=0;i<1000;i++) pkt[i]=3;
- for (int i=0;i<1000;i++)
- {
- plik2>>ruchy[i];
- }
- for (int i=0;i<1000;i++)
- {
- int x=0;
- int y=0;
- for (int j=0;j<ruchy[i].length();j++)
- {
- if (ruchy[i].at(j)=='N') y--;
- if (ruchy[i].at(j)=='S') y++;;
- if (ruchy[i].at(j)=='E') x++;
- if (ruchy[i].at(j)=='W') x--;
- if(x<0||y<0||x>19||y>19)
- {
- pkt[i]=-1;
- break;
- }
- pkt[i]=pkt[i]+plansza[x][y];
- }
- }
- int k=0;
- for (int i=0;i<1000;i++)
- {
- if (pkt[i]==-1) k++;
- }
- cout << "Liczba zdyskwalifikowanych graczy: " << k << endl;
- int maxx=0;
- int licz;
- for (int i=0;i<1000;i++)
- {
- if (pkt[i]>maxx)
- {
- maxx=pkt[i];
- licz=i;
- }
- }
- cout<<endl;
- cout <<"Numer gracza: " << licz+1 << endl;
- cout<<"Liczba punktow: "<<pkt[licz]<<endl;
- int gracz=0;
- for (int i=0;i<1000;i++)
- {
- for (int j=0;j<ruchy[i].length()-1;j++)
- {
- if ((ruchy[i].at(j)=='W'||ruchy[i].at(j)=='E')&&(ruchy[i].at(j+1)=='W'||ruchy[i].at(j+1)=='E'))
- {
- gracz++;
- }
- else if (gracz>wiersz[i])
- {
- wiersz[i]=gracz;
- gracz=0;
- }
- }
- }
- sort(wiersz, wiersz+1000);
- cout<<endl;
- cout << "Numer gracza: " << gracz<<endl;
- cout << "Najwieksza ilosc punktow: " << wiersz[999]<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement