예제 #1
0
파일: alg1.cpp 프로젝트: Quna/mspdev
int main ()
{
    std::cout << "STL generic algorithms -- initialization algorithms\n";
    
    fill_example ();
    copy_example ();
    generate_example ();
    swap_example ();
    
    std::cout << "End of initialization tests\n";
    
    return 0;
}
예제 #2
0
파일: dict.c 프로젝트: Uyouii/dict
int main()
{
	int driver=0, mode=VESA_800x600x8bit;
	int yes; 
	int i=0;
	int t=0;
	int style1=-1,style2=-1;
	char c;
	int n;
	int eee=0;

	initgraph(&driver, &mode, "");
	mydict();
	outtextxy(0,580,"Search:");
	
	while(strcmp(str,"exit")!=0&&strcmp(str,"quit")!=0)
	{
		num=0;
		clear_entry(str);
		if(eee==0)
		{
			t=bioskey(0);
		}
		eee=0;
		while(t!=Enter||num==0)
		{
			if(((char)t>=32&&(char)t<=126)||t==Bspace||t==ESC) 
			{
				if(t==Bspace)
				{
					if( num>0 ){
						num--;
						str[num] = '\0';
					}
				}
				else
				{
					if(t!=Enter)
					{
						c=t&0XFF;
						str[num++]=c;
						str[num] = '\0';
					}
				}
				if(t==ESC)
				{
					clear_entry(str);
					num=0;
				}
				input_entry();
				t=bioskey(0);
				
				if(num>=20)
				{
					clear_entry(str);
					num=0;
				}
			}
			else t=bioskey(0);
		}
		clear_translation();
		
		n=strlen(str);
		
		style1=-1;style2=-1;
		for(i=0;i<n;i++)
		{
			if(str[i]=='*'&&i<n) 	style1=i; 
			if(str[i]=='?'&&i<n) 	style2=i;
		}
		if(style1>0||style2>0)
		{
			search(str);
			if(count!=0) put_list();
		}
		
		show_translation(str);
			
		if(record>0) total=2;
		else total=1;
		show_page();
		if(record>0)
		{
			eee=1;
			t=bioskey(0);
			while(t==LEFT||t==RIGHT||t==DOWN||t==UP)
			{
				if(page==1&&(t==RIGHT||t==DOWN))
				{
					clear_translation();
					page++;
					copy_example( example, example2, record);
					put_translation2(example2);
					show_page();
				}
				if(page==2&&(t==LEFT||t==UP))
				{
					clear_translation();
					page--;
					show_translation(str);
					show_page();
				}
				t=bioskey(0);
			}	
		}
		for(i=0;i<2000;i++)
		{
			translation[i]=0;
			example[i]=0;
			example2[i]=0;
		}
		page=1;
		record=0;
	}
	closegraph();
	return 0; 
}
예제 #3
0
파일: dict.c 프로젝트: Uyouii/dict
void put_list( )//输出储存在list中的检索列表里面的内容
				//where 储存第一个单词在count中的序号 ,order是光标在列表中的位置 
{
	char p[25][20];
	char t1[10],t2[10];
	char t3[]="of";
	int i=0,t=0; 
	int x=10,y=30;
	
	clear_list();
	paint_color(order);
	if(count>=25)
	{
		for(i=0;i<25;i++)
		{
			strcpy(p[i],list[where+i]);
		}
		y=30;
		for(i=0;i<25;i++)
		{
			outtextxy(x,y,p[i]);
			y+=21;
		}
	}
	else
	{
		for(i=0;i<count;i++)
		{
			strcpy(p[i],list[where+i]);
		}
		y=30;
		for(i=0;i<count;i++)
		{
			outtextxy(x,y,p[i]);
			y+=21;
		}
	}
	while(t!=ESC)
	{
		if((order==1&&where>=0)||(order==25&&(where+order)<=count)||(t==PgUp&&where>0)||t==PgDn&&where+25<count||t==Home||t==End||t==Del||t==Ins)
		{
			clear_list();
			paint_color(order);
			if(count>=25)
			{
				for(i=0;i<25;i++)
				{
					strcpy(p[i],list[where+i]);
				}
				y=30;
				for(i=0;i<25;i++)
				{
					outtextxy(x,y,p[i]);
					y+=21;
				}
			}
			else
			{
				for(i=0;i<count;i++)
				{
					strcpy(p[i],list[where+i]);
				}
				y=30;
				for(i=0;i<count;i++)
				{
					outtextxy(x,y,p[i]);
					y+=21;
				}
			}
		}
		else
		{
			if(t==UP) 
			{
				setfillstyle(SOLID_FILL,BLACK);
				bar(5,30+order*21,185,51+order*21);
				outtextxy(10,order*21+30,p[order]);
				setfillstyle(SOLID_FILL,BLUE);
				bar(5,30+(order-1)*21,185,51+(order-1)*21);
				outtextxy(10,30+(order-1)*21,p[order-1]);
			}
			if(t==DOWN)
			{
				setfillstyle(SOLID_FILL,BLACK);
				bar(5,30+(order-2)*21,185,51+(order-2)*21);
				outtextxy(10,(order-2)*21+30,p[order-2]);
				setfillstyle(SOLID_FILL,BLUE);
				bar(5,30+(order-1)*21,185,51+(order-1)*21);
				outtextxy(10,30+(order-1)*21,p[order-1]);
			}
		}
		setfillstyle(SOLID_FILL,BLACK);
		bar(70,12,200,26);
		sprintf(t1,"%d",where+order);
		sprintf(t2,"%d",count);
		outtextxy(70,12,t1);
		outtextxy(70+strlen(t1)*8+4,12,t3);
		outtextxy(70+strlen(t1)*8+strlen(t3)*8+8,12,t2);
		
		t=bioskey(0);
		
		switch(t)
		{
			case DOWN:
				{
					if(order<25&&(where+order)<count) order++;
					else if(order==25&&(where+order)<count)
						{
							where++;
						}
					else ;
				}break;
			case UP:
				{
					if(order>1) order--;
					else if(order==1&&where>0) where--;
					else ;
				}break;
			case PgDn:
				{
					if(count<=25) ;
					else
					{
						if((where+50)>count) where+=count-where-25;
						else if(where+25>=count) ;
						else where+=25;
					}
				}break;
			case PgUp:
				{
					if((where-25)<0&&where>=-24) where=0;
					else if(where-25>=0) where-=25;
					else ;
				}break;
			case Home:
				{
					where=0;
				}break;
			case End:
				{
					if(count<=25) ;
					else  where=count-25;
				}break;
			case Enter:
				{
					clear_translation();
					strcpy(str,list[where+order-1]);
					show_translation(str);
					if(record>0) total=2;
					else total=1;
					show_page();
					if(record>0)
					{
						t=bioskey(0);
						while(t==LEFT||t==RIGHT)
						{
							if(page==1&&t==RIGHT)
							{
								clear_translation();
								page++;
				 				copy_example( example, example2, record);
				 				put_translation2(example2);
				 				show_page();
							}
							if(page==2&&t==LEFT)
							{
								clear_translation();
								page--;
								show_translation(str);
								show_page();
							}
							t=bioskey(0);
						}
					}
					for(i=0;i<2000;i++)
					{
						translation[i]=0;
						example[i]=0;
						example2[i]=0;
					}
					page=1;
					record=0;
				}break;
			case Ins:
				{
					order=1;
				}break;
			case Del:
				{
					if(count<25) order=count;
					else order=25;
				}break;
				
		}
	}
		
	clear_list();
	count=0;where=0;order=1;
	free(list);
	
}