All pastes #777553 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-11-16 21:43 UTC
rendered paste body

#include <stdio.h>

struct Piste {
        int x;
        int y;
} ; 

struct Piste luo_piste(int x1, int y1)  
{
struct Piste foo; 
foo.x = x1;
foo.y = y1;
return foo; 
}

struct Piste paikkavektoreiden_summa(int x1,int y1,int x2,int y2)
{
struct Piste foo;
foo.x = x1 + x2;
foo.y = y1 + y2;

return foo;
}


int main(void)
{


struct Piste arvot[3];  
struct Piste pl; 
struct Piste summavektori;

arvot[0].x = 1;
arvot[0].y = 2;

arvot[1].x = 3;
arvot[1].y = 2;

arvot[2].x = 6;
arvot[2].y = 4;

pl = luo_piste(5,9);  

printf("\nLuotu piste: (%i, %i) \n", pl.x, pl.y); 

summavektori = paikkavektoreiden_summa(1, 2, 3, 3); 

printf("\nPaikkavektoreiden summa: (%i, %i) \n", summavektori.x, summavektori.y);

}