今天晚上去「南哪」听了场AI的讲座,除了话筒真心不给力之外,算是对微软这方面的进展有了更多了解,毕竟是半宣传性质的活动吧。
光听这些是没用的,眼下还是打好基础,多尝试学点新技术,拓宽能力和视野比较重要。
比较匆忙,这次算是重新过了一遍过去写的代码,把命名和格式改进了一下。
Stack 栈的C++实现
main函数是把数字翻转输出
#include <iostream>
using namespace std;
typedef int dataType;
struct StackNode
{
dataType data;
StackNode * next;
};
class stack
{
StackNode *top =NULL;
int NodeNumber=0;
public:
int get_node_number()
{
return NodeNumber;
}
void push(dataType data)
{
StackNode *p=new StackNode;
p->data=data;
p->next=top;
top=p;
++NodeNumber;
}
dataType pop()
{
dataType popNum=this->top->data;
top = top->next;
--NodeNumber;
return popNum;
}
bool is_stack_full()
{
if (this->top == NULL)
return true;
else
return false;
}
};
int main() {
stack * n_stack=new stack;
int n;
cout<<"Input the number on the next line!"<<endl;
cin>>n;
while(n!=0)
{
n_stack->push(n%10);
n=n/10;
}
while(!n_stack->is_stack_full())
cout<<n_stack->pop();
return 0;
}
晚安世界!