?? 實驗三(4).cpp
字號:
#include "iostream.h"
#include "string.h"
#define maxlen 99
class stack
{
public:
stack();
bool kongde();
void Pust(int x);
int POP();
private:
int count;
int data[maxlen];
};
stack::stack()
{
count=0;
}
bool stack::kongde()
{
return (count==0);
}
void stack::Pust(int x)
{
data[count]=x;
count++;
}
int stack::POP()
{
count--;
return data[count];
}
void p11(int w)
{
stack s;
int array[30];
int j=0;
int f[10]={0,0};
int i=2;
for(i;i<10;i++)
f[i]=f[i-2]+f[i-1]+i-1;
while(w>0||!s.kongde())
{
while(w>0)
{
s.Pust(w);
array[j++]=w;
w=w-2;
}
if(!s.kongde())
{
w=s.POP();
w=w-1;
}
}
for(i=j-1;i>=0;i--)
cout<<array[i]<<","<<f[array[i]+1]<<endl;
}
void main()
{
p11(7);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -