Exemplo n.º 1
0
int
main(int argc, char *argv[])
{
	char *cmd_f = NULL;
	subcmd_f icmd = NULL;
	const char *cmd;
	int res = 0;

	init_cmds();
	if ((cmd = extract_cmd(argc, argv)) == NULL &&
	    /* try the rewriter */
	    (icmd = rewrite_subcmd(argc, argv)) == NULL) {
		ute_cmd_help(argc, argv);
		res = 1;

	} else if (cmd != NULL && (cmd_f = build_cmd(cmd)) != NULL) {
		/* prepare the execve */
		argv[0] = cmd_f;
		res = execv(cmd_f, argv);

	} else if (icmd != NULL || (icmd = get_subcmd(cmd)) != NULL) {
		/* call the internal command */
		res = icmd(argc, argv);

	} else {
		fprintf(stderr, "ute subcommand `%s' invalid\n\n", cmd);
		ute_cmd_help(argc, argv);
		res = 1;
	}
	return res;
}
Exemplo n.º 2
0
void FileSP::setFile(const std::string &file)
{
    std::ifstream input(file.c_str());
    std::string line;

    std::vector<double> E;
    std::vector<double> Sp;
    while ( next_line(input, line) ){
        std::stringstream icmd(line.c_str());
        double e, se, sn;
        icmd >> e;
        icmd >> se;
        icmd >> sn;
        E.push_back(e);
        Sp.push_back(se*1e-3 + sn*1e-3);
    }
    stop.set_points(E, Sp);
    fileSet = true;
    input.close();
}
Exemplo n.º 3
0
int main (void){
    icmd();
    start:;
    schwierigket=0;
    //standart frontpage
    system("title Mastermind");
    printf("Mastermind Programmiert von Simon Diepold\n");
    printf("drcke eine belibige Taste...");
    getchar();
    system("cls");
    printf("W„hlen sie eine schwierigkeits Stufe:\n"
           "Einfach(1)        [4 Stellen, keine gleichen Zahlen,8 Versuche]\n"
           "Herausfordernd(2) [4 Stellen, 6 Versuche]\n"
           "Schwer(3)         [8 Stellen, 6 Versuche]\n"
           "Beenden(4)        [beendet das Programm]\n"
           );

    while(1){
        schwierigket=getchar();
        if(schwierigket==0x31 ||schwierigket==0x32 || schwierigket==0x33 || schwierigket==0x34){
            if(schwierigket==0x34){
                goto end;
            }
            schwierigket-=0x30;
            ziffern=level[(schwierigket-1)];
            break;
        }
    }
    system("cls");

    //zufallsgenerator
    if(schwierigket==1){
        random(backup);
    }
    else if (schwierigket==2){
        randomLV2(backup);
    }
    else if (schwierigket==3){
        randomLV3(backup);
    }

    xprintf();
    versuch = 0;
    beginn:;
    int i=0;
    int x=0;
    while(i<8){
        result[i]=0; i++;
    }
    i=0;
    while(i<8){
        computer[i]=backup[i];
        i++;
    }
    i=0;
    playerinput(player,ziffern);
    x=check(ziffern);

    if (x==ziffern){
        printf("\ndu hast gewonnen! Gratulation!");
        getch();
        system("cls");
        goto start;
    }else{
    x+=compare(ziffern);
    set_posotion((ziffern+1),(versuch+1));

    i=0;
    while(i<x){
        result[i]+=0x30;
        printf("%c",result[i]);
        i++;
    }
    printf(" \n");

    if(versuch==rounds[schwierigket-1]){
            printf("\nleider verloren. Die L”sung ist:");
            dump_pc();
            getch();
            system("cls");
            goto start;
        }
    versuch++;
    goto beginn;
    }
    end:;
    return 0;
}