📄 store.cpp
字号:
#include <stdlib.h>
#include<iostream.h>
#include"store.h"
store::store()
{
var =NULL;
value = 0;
next = NULL;
}
store::store(char * cvar,int cval)
{
int i = 0;
while(*(cvar + i) != '\0')
i++;
var = new char[i];
while(i >= 0)
{
*(var + i) = *(cvar + i);
i--;
}
value = cval;
next = NULL;
}
bool store::equalVar(char * ival)
{
int i = 0;
while((*(ival + i)!= '\0')&&(*(var + i)!= '\0'))
{
if(*(ival + i) != *(var + i))
return false;
i++;
}
return true;
}
bool FindInStore(store * storeList,char * ivar,int &ival)
{
store * tempStore = NULL;
tempStore = storeList;
int * tempVal = &ival;
while(tempStore != NULL)
{
if(tempStore->equalVar(ivar))
{
*tempVal = tempStore->value;
return true;
}
tempStore = tempStore->next;
}
return false;
}
bool ChangeInStore(store * storeList,char * ivar,int ival)
{
store * tempStore = NULL;
tempStore = storeList;
while(tempStore != NULL)
{
if(tempStore->equalVar(ivar))
{
tempStore->value = ival;
return true;
}
tempStore = tempStore->next;
}
return false;
}
store insertIntoStore(store * storelist,char * cvar,int cval)
{
store * temp;
temp = new store(cvar,cval);
if(storelist != NULL)
temp->next = storelist;
return *temp;
}
int print(store * storelist)
{
store * temp;
temp = storelist;
if(temp == NULL)
{
cout<<"store is empty !"<<endl;
return 0;
}
while(temp != NULL)
{
cout<<"变量为:"<<temp->var<<" 变量值为:"<<temp->value<<endl;
temp = temp->next;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -