[ create a new paste ] login | about

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

sollasky - C, pasted on Nov 4:
#include<stdio.h>

int main ( void )
{
	int i,w;	
	int height = 100 ;
	int width = 100 ;
	int count = 0 ;

//	標準入力	
//	printf ( "入力(縦 横):" ) ;
//	scanf ( "%d %d", &height, &width ) ;

	if ( height<1||height>1000||width<1||width>1000 ){
		printf ( "入力値が不正です\n" ) ;
		return 1 ;
	}

	for  ( i = 0 ; i < height ; i++ ){
		w = width - ((i/2)%2)*2 ;
		count += (w/4)*2+((w%4==3)?2:(w%4)) ;
	}

	printf ( "縦=%d,横=%d の時%d個\n", height, width, count ) ;

	return 0 ;
}


Output:
1
縦=100,横=100 の時5000個


Create a new paste based on this one


Comments: