Skip to content

Instantly share code, notes, and snippets.

Created April 4, 2013 16:45
Show Gist options
  • Save anonymous/5311976 to your computer and use it in GitHub Desktop.
Save anonymous/5311976 to your computer and use it in GitHub Desktop.
// Test.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
//
#include <stdafx.h>
#include <iostream>
#include <conio.h>
#include <vector>
#include <iterator>
char a[10];
int b;
int k,s;
using namespace std;
int main(void)
{
//Aufbau des Feldes
vector<int> v2;
v2.push_back('a'); v2.push_back('b'); v2.push_back('c');
v2[0]=1; v2[1]=0; v2[2]=0;
vector<int> v1;
v1.push_back('a'); v1.push_back('b'); v1.push_back('c');
v1[0]=1; v1[1]=0; v1[2]=0;
vector<int> v0;
v0.push_back('a'); v0.push_back('b'); v0.push_back('c');
v0[0]=1; v0[1]=0; v0[2]=0;
cout<< v2[0];cout << v2[1];cout<< v2[2] << endl; // gibt 2 aus
cout<< v1[0];cout << v1[1];cout<< v1[2] << endl;
cout<< v0[0];cout << v0[1];cout<< v0[2] << endl;
//eingabe der bewegungsabfolge
cout<<"bitte geben Sie 1 fuer Links, 2 fuer Rechts und 3 fuer unten ein\n";
for ( b = 0 ; b < 10 ; b++)
{
cin>>a[b];
}
cout<<a[0];
cout<<a[1];
cout<<a[2];
cout<<a[3];
cout<<a[4];
cout<<a[5];
cout<<a[6];
cout<<a[7];
cout<<a[8];
cout<<a[9];
//Bewegen des Krans
k=0;
b=1;
switch(a[b])
{
case 1 :{k--;}
case 2 :{k++;}
case 3 :{
if(s==0)
{
if(v2[k]!=0)
{
s=v2[k];
v2[k]=0;
}
else
{
if(v1[k]!=0)
{
s=v1[k];
v1[k]=0;
}
else
{
if(v0[k]!=0)
{
s=v0[k];
v0[k]=0;
}
}
}
}
if(s!=0)
{
};
}
if( (k<0)||(k>3))
{
cout<<"Game over";
}
}
cout<<"\n"<<k;
cout<<"\n"<<s;
getch();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment