1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include <iostream>
#include <memory.h>
using namespace std;
int main(){
int samestate;
int incrstate;
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int temp;
bool test = true;
char hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
while(test == true){
cout << "Enter a number:";
cin >> temp;
a = b;
b = c;
c = d;
d = temp;
if(a==b && b==c && c==d){
samestate = 1;
}else{
samestate = 0;
}
if(b==a+1 && c==a+2 && d==a+3){
incrstate = 1;
}else{
incrstate = 0;
}
cout << "Pattern:" << a << b << c << d << endl;
cout<< "Same state:" << samestate << endl;
cout<< "Increment state:" << incrstate << endl;
}
}
|