コード例 #1
0
ファイル: gen_x_copy.c プロジェクト: Mityuha/gspp
void gen_x(int num)
{
	copy_request("get_mul", 1) ;
	sleep(1) ;
	int mul_tid = get_tid("get_mul_copy", 1) ;
	int mynum = copynum(myname, mytid) ;
	int mul_inpnum ;
	if(mynum == 1)
		mul_inpnum = 0;
	else if(mynum == 2)
		mul_inpnum = 1 ;
	else
	{
		printf("[%s][gen_x]:my copy num=%d, but conditions are only for 1 and 2\n",myname, mynum) ;
		pvm_exit() ;
		exit(0) ;
	}
	for(int i = 0 ; i < num; ++i)
	{
		pvm_initsend(PvmDataDefault) ;
		pvm_pkint(&mul_inpnum, 1, 1) ;
		int num = i + 1 ;
		pvm_pkint(&num, 1 ,1) ;
		pvm_send(mul_tid, i) ;
	}
return ;
}
コード例 #2
0
ファイル: Hulc 0.2 alpha.cpp プロジェクト: vovayrovsky/vtsm
int main (int argc, char **argv)
{
if (argc != 2)
    {
    txMessageBox("Haven't file for play");
    return 1;
    }
txTextCursor (false);
txCreateWindow (1080, 720);
txSetFillColor (TX_WHITE);

const char* logf = "DATA/log.txt";
FILE* log = fopen (logf, "a");

fprintf (log, "\n\n=========hulc started=========\n");

FILE* read = fopen (argv[1], "r");

COLORREF cvet = TX_WHITE;

Stack stk = {};
double pushch = 0;

double deystvie = 0;

int cmd = 0;

int element = 0;

double proga[MAXSYMBOLINCOMMANDFILE];

fprintf (log, "\n\n\n=========hulc read and printf to array of programm do =========\n");
    for ( ; element <= MAXSYMBOLINCOMMANDFILE; element++)
        {
        txSetColor (cvet);
        txSetFillColor (cvet);
        fscanf (read, "%lg", &deystvie);
        proga[element] = deystvie;
        fprintf (log, "hulc printf to array of programm %lg\n", deystvie);
/*        switch (deystvie)
            {
            case cmdLINE:       proga[element] = cmdLINE;                                                                                   element++;              break;
            case cmdBUCKET:     proga[element] = cmdBUCKET;                                                                                 element++;              break;
            case cmdJUMP:       proga[element] = cmdJUMP;                                                                                   element++;              break;
            case cmdOUT:        proga[element] = cmdOUT;                                                                                    element++;              break;
            case cmdCOLOR:      proga[element] = cmdCOLOR;                                                                                  element++;              break;
            case cmdCIRCLE:     proga[element] = cmdCIRCLE;                                                                                 element++;              break;
            case cmdRECTANGLE:  proga[element] = cmdRECTANGLE;                                                                              element++;              break;
            case cmdTRIANGLE:   proga[element] = cmdTRIANGLE;                                                                               element++;              break;
            case cmdADD:        proga[element] = cmdADD;                                                                                    element++;              break;
            case cmdPUSH:       proga[element] = cmdPUSH; element++; fscanf (read, "%lg", &pushch); proga[element] = pushch;                element++;              break;
            case cmdPUSHR:      proga[element] = cmdPUSHR; element++; fscanf (read, "%lg", &stk.ireg); proga[element] = stk.ireg;           element++;              break;
            case cmdPOPR:       proga[element] = cmdPOPR; element++; fscanf (read, "%lg", &stk.ireg); proga[element] = stk.ireg;            element++;              break;
            case cmdSUB:        proga[element] = cmdSUB;                                                                                    element++;              break;
            case cmdMUL:        proga[element] = cmdMUL;                                                                                    element++;              break;
            case cmdDIV:        proga[element] = cmdDIV;                                                                                    element++;              break;
            case cmdEXIT:       proga[element] = cmdEXIT;                                                                                                           break;
            }*/
        }
        element++;
        proga[element] = cmdEXIT;

    fprintf (log, "\n\n======hulc end read program and he start do this is program======\n\n\n");

    deystvie = 0;
    pushch = 0;
    element = 0;
    stk.ireg = 0;
    pushch = 0;
    stk.ireg = 0;
    for (int i = 0; i <= MAXSYMBOLINCOMMANDFILE; i++)
        {
        txSetColor (cvet);
        txSetFillColor (cvet);
        cmd = proga[element];
        switch (cmd)
            {
            case cmdCOPY: copynum (&stk);                                                element++; break;
            case cmdLINE: line (&stk);                                                   element++; break;
            case cmdPUSH: element++; pushch = proga[element]; stk.push (pushch);         element++; break;
            case cmdBUCKET: clearw (&stk);                                               element++; break;
            case cmdOUT: out (&stk);                                                     element++; break;
            case cmdJUMP: jump (&stk, &element);                                                    break;
            case cmdCOLOR: color (&stk, &cvet);                                          element++; break;
            case cmdCIRCLE: circle (&stk);                                               element++; break;
            case cmdRECTANGLE: rectangle (&stk);                                         element++; break;
            case cmdTRIANGLE: triangle (&stk);                                           element++; break;
            case cmdADD: stk.Vplus ();                                                   element++; break;
            case cmdPUSHR: element++; stk.ireg = proga[element]; stk.pushr (stk.ireg);   element++; break;
            case cmdPOPR: element++; stk.ireg = proga[element]; stk.popr (stk.ireg);     element++; break;
            case cmdSUB: stk.Vminus ();                                                  element++; break;
            case cmdMUL: stk.Vumnozhity ();                                              element++; break;
            case cmdDIV: stk.Vdeleniye ();                                               element++; break;
            case cmdIN: in(&stk);                                                        element++; break;
            case cmdEXIT: fprintf (log, "\n\n ========hulc end do programm, number 0========"); return 0;
            default: txMessageBox ("ERROR Code, program end.", "hulc"); fprintf (log, "ERROR Code, number 2\n"); return 1;
            }
        fprintf (log, "hulc do %d\n", cmd);
        }
    fprintf (log, "\n\n ========hulc end do programm, number 3 (but you haven't gave me cmdEXIT(you luser:) ))========");
    return 3;
    }