Home > Back-end >  Pray god help see program where there is a problem
Pray god help see program where there is a problem

Time:09-18

Is to use the queue output of Yang hui triangle, but there have been problems
#include
# define Max 9
The class queue {
Public:
The queue () {
The front=rear;
};
Bool empty () {
If (front==rear) return true;
return false;
};
Bool full () {
If (front %==Max - 1 rear) return true;
return false;
};
Int get_front (int & amp; X) {
If (empty ()) return 0;
X=data [Max (front + 1) %];
return 1;
};
Int append (int x) {
If (full ()) return 0;
Rear=Max (rear + 1) %;
Data (rear);
return 1;
};
Int serve () {
If (empty ()) return 0;
The front=Max (front + 1) %;
return 1;
};

Private:
Int the front and rear;
The int data (Max);
};

Void main () {
Int x, s1, s2, m, j, I;
X=1;
The queue q;
CoutQ.a ppend (x);
For (I=2; i<=8; I++) {
S1=0;
for(j=1; J<=I - 1; J++) {
Q.g et_front (s2);
Q.s erve ();
M=s1 + s2;
CoutQ.a ppend (m);
S1=s2;
}
Cout<1Q.a ppend (1);
}
}
  • Related