示例#1
0
int main()
{
	lcd_init();
	init_push_buttons();
	shaft_encoder_init();
	stepper_init();
	
	while (1) {
		char prog;
		
		lcd_clear();
		prog = wait_button("Choose program:");
		switch (prog) {
			case 1:
				part1();
				break;
			case 2:
				part2();
				break;
			case 3:
				part3(); 
				break;
			default:
				;  // do nothing
		}
	}
}
示例#2
0
int main()
{
	Company NetEase("NetEasy");
	Department part1("在线游戏事业部");
	Department part2("盘古游戏部");
	Department part3("雷火游戏部");
	Department part4("大话&梦幻游戏部");
	Company littleCompany("美术子公司");
	Department part5("人物原画部");
	Department part6("背景原画部");
	Department part7("武器原画部");

	NetEase.addDepartment(&part1);
	NetEase.addDepartment(&part2);
	NetEase.addDepartment(&part3);
	NetEase.addDepartment(&part4);
	NetEase.addDepartment(&littleCompany);
	littleCompany.addDepartment(&part5);
	littleCompany.addDepartment(&part6);
	littleCompany.addDepartment(&part7);

	NetEase.getDescription(std::string(""));
	
	NetEase.removeDepartment(&part3);
	NetEase.removeDepartment(&part4);
	NetEase.getDescription(std::string(""));
	return 0;
}
int main()
{
	part0();
	part1();
	part2();
	part3();
	part4();
	part5();
	part6();	
}
示例#4
0
int shell (int argc, char *argv[]) {
    char *s = malloc(INPUT_STRING_SIZE+1);			/* user input string */
    tok_t *t;			/* tokens parsed from input */
    int lineNum = 0;
    int fundex = -1;
    pid_t pid = getpid();		/* get current processes PID */
    pid_t ppid = getppid();	/* get parents PID */
    pid_t cpid, tcpid, cpgid;

    init_shell();

    printf("%s running as PID %d under %d\n",argv[0],pid,ppid);

    lineNum=0;
    char cwd[5000];
    fprintf(stdout, "%d: %s:", lineNum, getcwd(cwd,sizeof(cwd)));
    while ((s = freadln(stdin))) {
        t = getToks(s); /* break the line into tokens */
        fundex = lookup(t[0]); /* Is first token a shell literal */
        if(fundex >= 0) cmd_table[fundex].fun(&t[1]);
        else {
            pid = fork();

            if( pid == 0 ) { // child process
                // printf("%d\n", strlen(strstr(s,">")));
                int i;
                for(i=0; i<MAXTOKS && t[i]; i++) {
                    if (strcmp( t[i], ">") == 0) {
                        t[i]=NULL;
                        //printf("hello");
                        part4(t,t[i+1],">");
                    }
                    if (strcmp( t[i], "<") == 0) {
                        t[i]=NULL;
                        //printf("hello");
                        part4(t,t[i+1],"<");
                    }
                }
                part3(t);
                part2(t);

            } else if(pid<0) {
                perror( "Fork failed" );
                exit( EXIT_FAILURE );
            }
        }
        lineNum++;
        wait(NULL);

        fprintf(stdout, "%d: %s :", lineNum, getcwd(cwd,sizeof(cwd)));
    }
    return 0;
}
示例#5
0
//enables you to read input from or to write output to a file
void part4(tok_t *input,char * filename,char * c) {
    int newfd;

    if(c == ">") {
        //printf("PART 4\n");
        if ((newfd = open(filename, O_CREAT|O_WRONLY | O_APPEND, 0644)) < 0) {
            perror(input);
            exit(1);
        }

        dup2(newfd, 1);
        close(newfd);
    }
    if(c == "<") {
        if ((newfd = open(filename, O_RDONLY, 0644)) < 0) {
            perror(input);
            exit(1);
        }
        dup2(newfd,0);
        close(newfd);
    }
    part3(input);
    part2(input);
}
示例#6
0
IddUnitString::IddUnitString (const std::string &s)
    : m_original(s), m_converted(s)
{
    // remove differentiation between kg-H2O and kg-Air (will be kg/kg).
    // better to add kg-H2O and kg-air as separate SI base units?
    m_converted = boost::regex_replace(m_converted,boost::regex("-H2O"),"");
    m_converted = boost::regex_replace(m_converted,boost::regex("-[aA]ir"),"");
    m_converted = boost::regex_replace(m_converted,boost::regex("Water"),"");
    m_converted = boost::regex_replace(m_converted,boost::regex("DryAir"),"");

    // basic replacements
    m_converted = boost::regex_replace(m_converted,boost::regex("-"),"*");
    if (!boost::regex_search(m_converted,boost::regex("H2O"))) {
        m_converted = boost::regex_replace(m_converted,boost::regex("([2-9]+)"),"^\\1");
    }
    else {
        m_converted = boost::regex_replace(m_converted,boost::regex("H2O"),"H_{2}O");
    }
    m_converted = boost::regex_replace(m_converted,boost::regex("deltaC"),"K");
    m_converted = boost::regex_replace(m_converted,boost::regex("minutes"),"min");
    m_converted = boost::regex_replace(m_converted,boost::regex("dimensionless"),"");
    m_converted = boost::regex_replace(m_converted,boost::regex("Person"),"person");
    m_converted = boost::regex_replace(m_converted,boost::regex("Rotations Per Minute"),"rpm");
    m_converted = boost::regex_replace(m_converted,boost::regex("ohms"),"ohm");
    m_converted = boost::regex_replace(m_converted,boost::regex("VA"),"V*A");
    m_converted = boost::regex_replace(m_converted,boost::regex("deltaJ"),"J");
    m_converted = boost::regex_replace(m_converted,boost::regex("rev"),"cycle");
    m_converted = boost::regex_replace(m_converted,boost::regex("Ah"),"A*h");

    // relative temperatures
    if (!boost::regex_match(m_converted,boost::regex("C|F"))) {
        m_converted = boost::regex_replace(m_converted,boost::regex("C"),"K");
        m_converted = boost::regex_replace(m_converted,boost::regex("F"),"R");
    }

    // Multiple /'s
    boost::smatch matches;
    if (boost::regex_match(m_converted,matches,boost::regex("(.*)/\\((.*)/(.*)\\)"))) {
        std::string part1(matches[1].first, matches[1].second);
        std::string part2(matches[2].first, matches[2].second);
        std::string part3(matches[3].first, matches[3].second);
        m_converted = part1 + "*" + part3 + "/" + part2;
    }

    if (boost::regex_match(m_converted,matches,boost::regex("\\((.*)/(.*)\\)/(.*)"))) {
        std::string part1(matches[1].first, matches[1].second);
        std::string part2(matches[2].first, matches[2].second);
        std::string part3(matches[3].first, matches[3].second);
        m_converted = part1 + "/" + part2 + "*" + part3;
    }

    if ((!m_converted.empty()) && boost::regex_search(m_converted,boost::regex("g"))) {
        Unit temp = parseUnitString(m_converted);

        // g -> m(kg)
        int gExp = temp.baseUnitExponent("g");
        if (gExp != 0) {
            temp.setBaseUnitExponent("g",0);
            temp.setBaseUnitExponent("kg",gExp);
            bool ok = temp.setScale(-3 * gExp);
            if (ok) {
                m_converted = temp.standardString();
            }
        }
    }

    if ((!m_converted.empty()) && boost::regex_search(m_converted,boost::regex("micron"))) {
        Unit temp = parseUnitString(m_converted);

        int gExp = temp.baseUnitExponent("micron");
        if (gExp != 0) {
            temp.setBaseUnitExponent("micron",0);
            temp.setBaseUnitExponent("m",gExp);
            bool ok = temp.setScale(-6 * gExp);
            if (ok) {
                m_converted = temp.standardString();
            }
        }
    }
}
void main( )
{
	part1( ); //call the function responsible for part 1
	part3( ); //call the functions for part 2 and 3 of the project
	getchar( );
}
示例#8
0
文件: B.C 项目: AoJ/SecondReality
main(int argc,char *argv[])
{
	int	endcnt=0;
	FILE	*f1;
	unsigned u;
	int	a,b,c,d,e,x,y,x2,y2,y1;
	dis_partstart();
	{
		_asm mov ax,13h
		_asm int 10h
	}
	waitb();
	memset(vram0,15,64000);
	while(dis_muscode(1)!=1 && !dis_exit());
	waitb();
	waitb();
	waitb();
	waitb();
	for(x=319;x>=0;x--)
	{
		vram0[x+100*320]=0;
		if(!(x&15)) waitb();
	}
	y1=100; a=100*64; b=0;
	while(y1<200)
	{
		b+=16;
		a+=b;
		y2=a/64;
		if(y2>200) y2=200;
		for(y=y1;y<y2;y++)
		{
			memset(vram0+y*320,0,320);
		}
		y1=y2;
		waitb();
	}
	for(a=0;a<70 && !dis_exit();a++) dis_waitb();
	
	memset(defpal,0,768);
	loadpal(defpal,768);
	outp(0x3c0,0x11+0x20);
	outp(0x3c0,255);
	memset(vram0+0*320,255,35*320);
	memset(vram0+35*320,254,1*320);
	memset(vram0+36*320,0,128*320);
	memset(vram0+164*320,254,1*320);
	memset(vram0+165*320,255,35*320);
	defpal[0*3+0]=0;
	defpal[0*3+1]=0;
	defpal[0*3+2]=20;
	defpal[254*3+0]=45;
	defpal[254*3+1]=45;
	defpal[254*3+2]=45;
	defpal[255*3+0]=0;
	defpal[255*3+1]=0;
	defpal[255*3+2]=0;
	loadpal(defpal,768);
	for(a=0;a<200;a++) rows[a]=a*320;
	background=halloc(16384L,4L);
	memset(background,0,64000);
	dotspnt=dots1;
	if(argc==2) 
	{
		switch(*argv[1])
		{
		case '1' : dotspnt=dots4; break;
		case '2' : mode=5; break;
		case '3' : mode=6; break;
		}
		for(a=0;a<256;a++) vram0[a]=vram0[a+320]=a;
		border=1;
	}
	x=y=c=0;
	
	for(a=0;a<256;a++) vram0[a]=vram0[a+320]=255;
	border=0;
	
	while(!dis_exit() && mode!=-1)
	{
		count++;
		setborder(255);
		waitb();
		if(mode==4 && count>0) loadpal(pal,768);
		if(mode==5 && count>500-17) loadpal(pal,768-6);
		if(mode==6 && count>0 && count<20) loadpal(pal,768-6);
		setborder(0);
		if(mode<4) dodots(background,vram);
		else if(mode==4) dodots2(background,vram);
		switch(mode)
		{
		case 0:
			if(count>32) 
			{ 
				NEXTMODE; 
			}
			break;
		case 1:
			if(!count) 
			{
				x=0;
				part1init();
			}
			else part1();
			break;
		case 2:
			{ 
				NEXTMODE;
				if(dotspnt==dots1) { mode=1; dotspnt=dots2; }
				else if(dotspnt==dots2) { mode=1; dotspnt=dots3; }
				else if(dotspnt==dots3) { mode=1; dotspnt=dots4; }
				else for(a=0;a<2048;a++) adddot(0,0,0,0,0);
			}
			break;
		case 3:
			if(count>40) NEXTMODE;
			break;
		case 4:
			if(count>400) 
			{ 
				NEXTMODE; 
			}
			if(!count)
			{
				pal1colp=1;
				memset(background,0,64000);
				for(dotsp=a=0;a<2048;a++)
				{
					dotsp+=4;
					switch(dotspnt[dotsp])
					{
					case 1 :
					case 2 :
					case 3 : doit2(dotspnt[dotsp+2],dotspnt[dotsp+3],254); break;
					default : dotsp=0; break;
					}
				}
				for(a=3;a<32*3;a+=3) 
				{
					pal[a+0]=0;
					pal[a+1]=0;
					pal[a+2]=20;
				}
			}
			a=252-pal1colp;
			d=a+66; if(d>254) d=254;
			c=63;
			for(;a<d;a++,c-=4)
			{
				if(c<0) c=0;
				b=c*c/64;
				pal[a*3+0]=b;
				pal[a*3+1]=b;
				pal[a*3+2]=b<20?20:b;
			}
			a=(254-65);
			pal[a*3+0]=63;
			pal[a*3+1]=63;
			pal[a*3+2]=63;
			pal[1*3+0]=63;
			pal[1*3+1]=63;
			pal[1*3+2]=63;
			pal1colp++;
			if(count>100) 
			{
				for(a=0;a<2048;a++) adddot(0,0,0,0,0);
				NEXTMODE;
			}
			break;
		case 5:
			if(!count) 
			{
				for(u=0;u<128*320;u++)
				{
					if(vram[u]==254-65) vram[u]=1;
					else vram[u]=0;
				}
				part2init();
			}
			else part2();
			break;
		case 6:
			if(!count) 
			{
				part3init();
			}
			else part3();
			break;
		case 7:
			NEXTMODE;
			if(count>100)
			{ 
				NEXTMODE; 
			}
			break;
		default : 
			mode=-1;
			break;
		}
	}
	if(!dis_indemo())
	{
		_asm mov ax,3h
		_asm int 10h
	}