Beispiel #1
0
int main(int argc, char *argv[])
{
  int i;

  InitList(&filelist);
  if (argc == 1)
    copyfile(stdin);
  else
  {
    for (i = 1; i < argc; i++)
      addfile(argv[i]);
    WalkList(&filelist, (WordFnPtr)putfile, 0);
  }
  return 0;
}
Beispiel #2
0
//inicializace pole funkci
tChyba initFunction()
{
	funcSize = 10;
	currFuncSize = 0;
	func = (TFunction*)malloc(sizeof(TFunction)*funcSize);
	if( !func ){
		return S_INTERNI_CHYBA;
	}
	for (int i = 0; i < funcSize; ++i){
		func[i].key = NULL;
		InitList( &(func[i].instrList) );
		func[i].table = NULL;
	}
	return S_BEZ_CHYB;
}
Beispiel #3
0
void InitHashTable(hashTablePrivate **htptr, int M,
                   int valueSize, void (*print)(), double (*equal)(),
                   unsigned long long int (*hashFun)(), void (*destroyValue)()) {

    *htptr = malloc(sizeof(hashTablePrivate));
    hashTablePrivate *ht = *htptr;
    ht->table = malloc(sizeof(List)*M);
    int i;
    for (i = 0; i < M; ++i) {

        InitList(&ht->table[i], valueSize, print, equal, destroyValue);
    }
    ht->hashFun = hashFun;
    ht->M = M;
    ht->size=0;
}
Beispiel #4
0
int main()
{	DLinkList *L;
	int choice;
	InitList(L);
	int length;
	ElemType *a;
	length = readInput(a);
	CreateList(L , a ,length);
	DispList(L);
	while(1 == scanf("%d",&choice))
	{	LocateNode(L,choice);
		DispList(L);
	}
	
	return 0;
}
Beispiel #5
0
Status CreatPolyn(polynomail *p, int m) {
	int i, expn;
	double coef;
	ElemType e;
	Link *s;
	if (InitList(p) == ERROR)return ERROR;
	for (i = 0; i < m; i++) {
		printf("请输入第%d项的系数和指数:", i + 1);
		scanf("%lf%d", &coef, &expn);
		if (SetPolyn(&e, coef, expn) == ERROR)return ERROR;	//输入数据,形成数据域
		if (MakeNode(&s, e) == ERROR)return ERROR;			//包装进一个结点
		if (Append(p, s) == ERROR)return ERROR;				//将结点插入链表尾
	}
	SortPolyn(p);											//再慢慢排序
	return OK;
}
Beispiel #6
0
void CDashArrayDlg::OnBnClickedButtonrmv()
{
	if ( m_pDashArray == NULL )
	{
		return;
	}
	Update();
	if( m_iIndex == 1 )
	{
		::MessageBox(AfxGetApp()->GetMainWnd()->m_hWnd , "数组个数最少为1!" , "警告" ,MB_OK);
		return;
	}

	m_pDashArray->RemoveDash( m_iIndex - 1 );
	m_pDashArray->SetDashGroupCount(m_pDashArray->GetDashGroupCount() - 1);
	InitList();
}
Beispiel #7
0
 void Algo10_11_main()
 {
   RedType d[N]={{278,1},{109,2},{63,3},{930,4},{589,5},{184,6},{505,7},{269,8},{8,9},{83,10}};
   SLList l;
   int *adr;
   InitList(l,d,N);
   printf("排序前(next域还没赋值):\n");
   print(l);
   RadixSort(l);
   printf("排序后(静态链表):\n");
   print(l);
   adr=(int*)malloc((l.recnum)*sizeof(int));
   Sort(l,adr);
   Rearrange(l,adr);
   printf("排序后(重排记录):\n");
   print(l);
 }
Beispiel #8
0
int main()
{
    LinkList L;
    InitList(&L);
    Link test=NULL;
    ElemType array[10] = {10,9,8,7,6,5,4,3,2,1};
    /*ElemType array[10] = {0,9,8,7,6,5,4,3,2,1};*/

    CreateListByArray(array,sizeof(array)/sizeof(ElemType),&L,&InsFirst);
    printf("Length= %d\n",ListLength(L));
    LocatePos(L,9,&test);
    printf("第9个节点数据为%d\n",test->data) ;
    printf("%s\n","------------------------------------") ;
    ListTraverse(L,&Myvist);
    DestroyList(&L);
    return 0;
}
Beispiel #9
0
int AddToMap(Map* mp, char* key, void* value) {
	if (!mp) return 0;
	List* ls = FindInHashTable(mp->tb,key);
	if (!ls) {
		ls = InitList();
		if (!InsertIntoHashTable(mp->tb,key,ls)) {
			printf("Warning(Map): cannot insert %s into hash table!\n",key);
			return 0;
		}
		mp->size++;
	}
	if (!AppendToList(ls,value)) {
		printf("Warning(Map): cannot append to list!\n");
		return 0;
	}
	return 1;
}
Beispiel #10
0
void Test1()//PushBack   PopBack
{
	PSListNode pHead = NULL;
	InitList(&pHead);
	PushBack(&pHead,0);
	PushBack(&pHead,1);
	PushBack(&pHead,2);
	PushBack(&pHead,3);
	PushBack(&pHead,4);

	PrintList(&pHead);

	PopBack(&pHead);
	PopBack(&pHead);

	PrintList(&pHead);
}
void CCardopenConsumeView::OnInitialUpdate()
{
	CIBAFormView::OnInitialUpdate();

	m_STATICResult.SetFont(&m_Font);
	m_STATICResult.SetWindowText(_T(""));

	InitTimeCtrl();

	InitDate();

	InitList();

	GetDlgItem(IDC_BUTTON_QUERY)->SetFocus();

	// 2011/12/28-8236-gxx: 自动查询一次
	OnBnClickedButtonQuery();
}
Beispiel #12
0
/********************************************************************
	Method:    CreateListByTail
	Parameter: 单链表,元素个数
	Returns:

	Purpose:   尾插法建立单链表

*********************************************************************/
bool CreateListByTail(LinkList &L, int num)
{
    InitList(L);

    Node *tail = L;

    for (int i = 0; i < num; i++)
    {
        Node *s = (Node *)malloc(sizeof(Node));
        s->e.data = i + 1;
        s->next = NULL;

        tail->next = s;
        tail = s;
    }

    return true;
}
Beispiel #13
0
Permanent* NewPermanent(MTGCard* source,MTGPlayer* own) {
    Permanent* p = (Permanent*) calloc(1,sizeof(Permanent));
    p->name = source->name;
    p->subtypes = source->subtypes;
    p->abilities = ListCopy(source->abilities);
    if (source->subtypes.is_planeswalker)
        p->loyalty = source->loyalty;
    else if (source->subtypes.is_creature){
        p->power = p->sourcePower = source->power;
        p->toughness = p->sourceToughness = source->toughness;
        p->has_summoning_sickness = true;
    }
    p->equipment = InitList();
    p->source = source;
    p->owner = own;
    p->controller = own;
    return p;
}
Beispiel #14
0
/********************************************************************
	Method:    CreateListByHead
	Parameter: 单链表, 元素个数
	Returns:

	Purpose:   头插法建立单链表

*********************************************************************/
bool CreateListByHead(LinkList &L, int num)
{
    InitList(L);

    for (int i = 0; i < num; i++)
    {
        //	建立节点
        Node *s = (Node *)malloc(sizeof(Node));
        s->e.data = i + 1;
        s->next = NULL;

        //	插入
        s->next = L->next;
        L->next = s;
    }

    return true;
}
Beispiel #15
0
/**
 * @brief Initialize the dialog.
 */
BOOL PluginsListDlg::OnInitDialog()
{
	theApp.TranslateDialog(m_hWnd);
	CDialog::OnInitDialog();
	
	InitList();
	AddPlugins();

	BOOL pluginsEnabled = GetOptionsMgr()->GetBool(OPT_PLUGINS_ENABLED);
	if (pluginsEnabled)
	{
		CButton *btn = (CButton *)GetDlgItem(IDC_PLUGINS_ENABLE);
		btn->SetCheck(BST_CHECKED);
	}

	return FALSE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Beispiel #16
0
qtDLGPEEditor::qtDLGPEEditor(clsPEManager *PEManager,QWidget *parent, Qt::WFlags flags, int PID, std::wstring FileName)
	: QWidget(parent,flags)
{
	setupUi(this);
	
	this->setStyleSheet(clsHelperClass::LoadStyleSheet());
	this->setLayout(verticalLayout);
	this->setAttribute(Qt::WA_DeleteOnClose,true);

	connect(treePE,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(OnCustomContextMenu(QPoint)));
	connect(new QShortcut(Qt::Key_Escape,this),SIGNAL(activated()),this,SLOT(close()));

	m_processID = PID;
	m_pEManager = PEManager;
	
	if(m_pEManager != NULL)
	{	
		if(FileName.length() > 0)
			m_currentFile = FileName;
		else
			m_currentFile = m_pEManager->getFilenameFromPID(m_processID);

		if(m_processID == -1)
			m_pEManager->OpenFile(m_currentFile);

		if(m_currentFile.length() <= 0) 
		{
			QMessageBox::critical(this,"Nanomite","Could not load File!",QMessageBox::Ok,QMessageBox::Ok);

			close();
		}

		this->setWindowTitle(QString("[Nanomite] - PEEditor - FileName: %1").arg(QString::fromStdWString(m_currentFile)));

		InitList();
		LoadPEView();
	}
	else
	{
		QMessageBox::critical(this,"Nanomite","Could not load File!",QMessageBox::Ok,QMessageBox::Ok);

		close();
	}
}
int main(int argc, const char * argv[]) {

    LinkList list, *L;
    Node *t;
    L = &list;
    
    InitList(L);
    ListInsert(L, 1, 12);
    ListInsert(L, 2, 13);
    ListInsert(L, 1, 14);
    ListInsert(L, 1, 15);
    ListInsert(L, 1, 16);
    ListInsert(L, 3, 17);
    t = LocateElem(L, 14);
    printf("%d \n", t->data);
    VisitList(L);
    DestroyList(L);
    return 0;
}
Beispiel #18
0
int main(){
	DuLinkList L;
	int i, n;

	InitList(&L);

	printf("please enter an integer:");
	scanf("%d", &n);
	printf("\n");

	Caesar(&L, n);

	for(i = 0; i< 26; i++){
		L = L->next;
		printf("%c", L->data);
	}
	printf("\n");
	return 0;
}
Beispiel #19
0
BOOL CDLGSetFace::OnInitDialog() 
{
	CDialog::OnInitDialog();

	// TODO: Add extra initialization here

	//初始化列表
	InitList();

	m_b_ok.LoadBitmaps(IDB_OK_BUTTON,IDB_OK_BUTTON_MOVE,NULL,NULL);
	m_b_ok.SizeToContent();		//自适应图片大小

	m_b_cancel.LoadBitmaps(IDB_CANCEL_BUTTON,IDB_CANCEL_BUTTON_MOVE,NULL,NULL);
	m_b_cancel.SizeToContent();		//自适应图片大小


	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Beispiel #20
0
int main(int argc, char *argv[])
{
  int sctcp;
  char hostname[80] = "";
  struct sockaddr_in SC_link = { 0 };
  int server_port=8000;
  int childPid=0;
  static LList userlist;
  InitList(&userlist);
  pthread_t id;
  int ret;

  printf("Server is starting\n");
  sctcp=tcpSocket();	//client-server comunicate with tcp
  Setsockopt(sctcp);		//set SO_REUSEADDR,SO_LINGER opt
  GetHostName(hostname, sizeof(hostname));
  CreateSockAddr(hostname,&SC_link,server_port);
  Bind(sctcp, (struct sockaddr *) &SC_link,sizeof(SC_link));
  Listen(sctcp);
  printf("Server started successfully and it is ready now\n");
  printf("Now entered listening mode\n");
  for (;;)
  {
    struct sockaddr_in client_sockaddr = { 0 };
    int cli_socket, cli_sock2,clientLength = sizeof(client_sockaddr);
    (void) memset(&client_sockaddr, 0, sizeof(client_sockaddr));
    cli_socket = Accept(sctcp,(struct sockaddr *) &client_sockaddr, &clientLength);
    if (-1 == cli_socket)
    {
      perror("accept()");
    }
    threadargs newargs;
    newargs.sock=cli_socket;
    newargs.list=&userlist;
    //      accept_cli(&newargs);
    ret=pthread_create(&id,NULL,(void *)accept_cli,&newargs);
    if(ret!=0)
      perror("thread create error");
  }


  return EXIT_SUCCESS;
}
Status	MergeLinkList(LinkList	*La,
					  LinkList	*Lb,
					  LinkList	*Lc,
					  int		(*compare)(ElemType, ElemType))
/* 已知单链表La和Lb的元素按值非递减排列
 * 归并La和Lb得到新的单链表Lc, Lc的元素也按值非递减排列.
 */
{
	Link pNode_La = La->head, ha = GetHead(*La),
		 pNode_Lb = Lb->head, hb = GetHead(*Lb);
	int  iLen_La  = La->len,  iLen_Lb  = Lb->len;
	ElemType a = 0, b = 0;
	Link pTemp = NULL;

	if (!InitList(Lc))	// Initialize link list Lc.
		return ERROR;
	while (pNode_La && pNode_Lb)
	{
		a = GetCurElem(pNode_La);
		b = GetCurElem(pNode_Lb);
		if (0 >= (*compare)(a, b))
		{
			DelFirst(&ha, &pTemp);
			Append(Lc, pTemp);
			pNode_La = NextPos(*La, ha);
		}
		else
		{
			DelFirst(&hb, &pTemp);
			Append(Lc, pTemp);
			pNode_Lb = NextPos(*Lb, hb);
		}
	}
	if (pNode_La)
		Append(Lc, pNode_La);
	else
		Append(Lc, pNode_Lb);

	FreeNode(&ha);
	FreeNode(&hb);
	return OK;
}
Beispiel #22
0
extern "C" int __declspec(dllexport) Load(void)
{
	mir_getLP(&pluginInfo);

	// ensure datetime picker is loaded
	INITCOMMONCONTROLSEX ccx;
	ccx.dwSize = sizeof(ccx);
	ccx.dwICC = ICC_DATE_CLASSES;
	InitCommonControlsEx(&ccx);

	HookEvent(ME_SYSTEM_MODULESLOADED,MainInit);
	HookEvent(ME_SYSTEM_PRESHUTDOWN, MainDeInit);

	LoadOptions();
	InitList();

	HookEvent(ME_OPT_INITIALISE, OptInit );

	return 0;
}
BOOL CSelectMemberDlg::OnInitDialog()
{
	CElcSkinDialog::OnInitDialog();

	AdjustImagePanePos(IDC_IMAGE_PANE);
	BindButton(ID_BTN_OK);
	BindButton(ID_BTN_CANCEL);
	BindButton(IDC_BTN_HELP);

	m_wndIcon.SubclassDlgItem(IDC_SELECT_STUDENT_ICON, this);
	m_wndIcon.SetImage(IDR_RT_SELECT_STUDENT);

	CBitmap bmpBase;
	m_imgList.Create(16, 16, ILC_MASK | ILC_COLOR24, 0, 1);
	bmpBase.Attach(::LoadImage(AfxGetResourceHandle(), MAKEINTRESOURCE(IDB_GROUP_LIST_STATE), 
		IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE | LR_CREATEDIBSECTION));
	m_imgList.Add(&bmpBase, RGB(255,0,255));

	m_wndMemberList.SetImageList(&m_imgList, LVSIL_SMALL);
	m_wndMemberList.SetBkColor(RGB(250,250,250));

	m_wndMemberList.SetExtendedStyle(m_wndMemberList.GetExtendedStyle() | LVS_EX_CHECKBOXES);

	if (m_pTeacherFrame)
	{
		DWORD dwMask;
		dwMask = ITeacherFrame::ELC_MEMBER_CONNECTED | 
				 ITeacherFrame::ELC_MEMBER_DISCONNECTED | 
				 ITeacherFrame::ELC_MEMBER_ADDED | 
				 ITeacherFrame::ELC_MEMBER_REMOVED |
				 ITeacherFrame::ELC_MEMBER_NAMECHANGED |
				 ITeacherFrame::ELC_MEMBER_HANDUP |
				 ITeacherFrame::ELC_MEMBER_HANDDOWN |
				 ITeacherFrame::ELC_FUNCTION_CHANGED;
		m_pTeacherFrame->RegisterCallback(dwMask, this, NULL);
	}

	InitList();

	return TRUE;
}
Beispiel #24
0
BOOL CDlgAlarmAnalysis::OnInitDialog()
{
	CDialog::OnInitDialog();

	const CTime tMin(1978,1,1,0,0,0);
	const CTime tMax(2038,1,1,0,0,0);

	m_wndBeginTime.SetFormat(_T("yyyy年MM月dd日 dddd"));
	m_wndBeginTime.SetRange(&tMin, &tMax);

	m_wndEndTime.SetFormat(_T("yyyy年MM月dd日 dddd"));
	m_wndEndTime.SetRange(&tMin, &tMax);

	InitList();
	ReDrawListData();
	ReDrawListBox();

	GetSetTime(&m_nOldBeginTime, &m_nOldEndTime);

	return TRUE;  // return TRUE unless you set the focus to a control
}
Beispiel #25
0
BOOL CDlgAllCheckOut::OnInitDialog()
{
	CIBADialog::OnInitDialog();

	

	m_listCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_NOSORTHEADER);
	m_listCtrl.SetItemsHeight(20);


	InitList();
	FillList();

	GetDlgItem(IDC_EDIT_FIND)->SetFont(&m_Font);
	GetDlgItem(IDC_STATIC_INFO)->SetFont(&m_Font);
	GetDlgItem(IDC_STATIC_RESULT)->SetFont(&m_Font);

	m_GridCtrl.ShowWindow(FALSE);

	return FALSE;  // return TRUE unless you set the focus to a control
}
Beispiel #26
0
/* Makes a copy of a list */
struct List *CpyList(int ListSize, int NodeSize, const struct List *List, const char *Name)
{
  struct List *Copy;
  struct Node *Node, *NewNode;
  Copy=(struct List *)malloc(ListSize);
  if (Copy==NULL) return(NULL);
  memcpy(Copy,List,ListSize);
  InitList(Copy);
  if (Name!=CL_CPY_NAME) strncpy(Copy->Head.Name,Name,NODE_NAME_LENGTH);
  for(Node=(struct Node *)List->Head.Succ; Node!=&(List->Tail); Node=Node->Succ)
    {
      NewNode=CpyNode(NodeSize,Node,CN_CPY_NAME);
      if (NewNode==NULL) 
	{
	  FreeList(Copy);
	  return(NULL);
	};
      AddHead((*Copy),NewNode);
    };
  return(Copy);
}
Beispiel #27
0
#include "sqlist.cpp"   /*假设线性表以顺序表表示*/
void main()
{
	SqList *L;
	ElemType e;
	InitList(L);
	ListInsert(L,1,'a');
	ListInsert(L,2,'c');
	ListInsert(L,3,'a');
	ListInsert(L,4,'d');
	ListInsert(L,5,'b');
	printf("ListLength(L)=%d\n",ListLength(L));
	printf("ListEmpty(L)=%d\n",ListEmpty(L));
	GetElem(L,3,e);
	printf("e=%c\n",e);
	printf("LocateElem(L,'a')=%d\n",LocateElem(L,'a'));
	ListInsert(L,4,'e');
	DispList(L);
	ListDelete(L,3,e);
	DispList(L);
	DestroyList(L);
}
int main()
{
    DualLinkList L;
    int i, n;

    InitList(&L);

    printf("Please Input a number:\n");
    scanf("%d",&n);
    Caesar(&L, n);

    for(i=0;i<26;i++)
    {
        L=L->next;
        printf("%c",L->data);
    }

    printf("\n");
    
    return 0;
}
Beispiel #29
0
MTGPlayer* InitMTGPlayer() {
	MTGPlayer* p = (MTGPlayer*)malloc(sizeof(MTGPlayer));
    p->marker = (Permanent*)calloc(1,sizeof(Permanent));
	p->library=InitList();
	p->hand=InitList();
    p->graveyard=InitList();
    p->exile=InitList();
    p->lands=InitList();
    p->battlefield=InitList();
    p->playedLand = false;
    p->canConvoke = true;
    memset(p->mana,0,6 * sizeof(int));
    memset(p->convokeMana, 0, 6*sizeof(int));
    p->hp=80;
	return p;
}
Beispiel #30
0
void main()
{
	LinkList L;
	ElemType e;
	int j;
	Status i;
	InitList(L);
	i = ListEmpty(L);
	printf("L是否空 i = %d (1:空 0:否)\n", i);
	ListInsert(L, 1, 3);
	ListInsert(L, 2, 5);
	i = GetElem(L, 1, e);
	j = ListLength(L);
	printf("L中的数据元素个数=%d, 第一个数据元素的值为%d.\n", j, e);
	printf("L中的数据元素依次为:");
	ListTraverse(L, print);
	PriorElem(L, 5, e);
	printf("5前面的元素的值为%d.\n", e);
	NextElem(L, 3, e);
	printf("3后面的元素的值为%d.\n", e);
	printf("L是否空 %d(1:空 0:否)\n", ListEmpty(L));
	j = LocateElem(L, 5, equal);
	if ( j )
		printf("L的第%d个元素为5.\n", j);
	else
		printf("不存在值为5的元素.\n");
	i = ListDelete(L, 2, e);
	printf("删除L的第2个元素:\n");
	if ( i )
	{
		printf("删除的元素值为%d, 现在L中的数据元素依次为", e);
		ListTraverse(L, print);
	}
	else
		printf("删除不成功!\n");
	ClearList(L);
	printf("清空L后, L是否空:%d (1:空 0:否)\n", ListEmpty(L));
	DestroyList(L);
}