[ create a new paste ] login | about

Link: http://codepad.org/igeaiHuI    [ raw code | output | fork ]

C, pasted on Feb 7:
#include<stdio.h>

void func(int bx,int ex,int by,int ey)
{
	int addx,addy;
	int i;
		
	printf("x=%d",bx);
	for(i=bx+1;i<=ex;i++)
	{
		printf("+%d",i);
	}
	printf("=%d\n",addx=(ex-bx+1)*(bx+ex)/2);
	
	printf("y=%d",by);
	for(i=by+1;i<=ey;i++)
	{
		printf("+%d",i);
	}
	printf("=%d\n",addy=(ey-by+1)*(by+ey)/2);
	
	printf("x*y=%d\n",addx*addy);
}
	
int main(void)
{
	int begin_x,begin_y,end_x,end_y;
	
	begin_x=2;
	begin_y=4;
	end_x=6;
	end_y=5;
	
	func(begin_x,end_x,begin_y,end_y);
	
	return 0;
}


Output:
1
2
3
x=2+3+4+5+6=20
y=4+5=9
x*y=180


Create a new paste based on this one


Comments: