U E D R , A S I H C RSS

구구단/곽세환

데블스캠프2003첫째날 구구단짜기

~cpp 
#include <iostream>
using namespace std;

int main()
{
	int i,j,k;
	i=1;
	j=1;
	k=2;
	while(i!=3)
	{
		cout << k+(i-1)*4 << " * " << j << " = " << (k+(i-1)*4) * j << "\t";
		k++;
		if (k==6)
		{
			cout << "\n";
			j++;
			k=2;
		}
		if (j==10)
		{
			cout << "\n";
			i++;
			j=1;
		}
	}
	return 0;
}

스킴으로 짠 구구단
~cpp 
(define (ggd x y)
  (begin (print x) (print *) (print y) (print =) (print (* x y)) (newline)))
(define (iter x y)
  (when (<= x 9)
    (if (< y 9) (begin (ggd x y) (iter x (+ y 1)))
        (begin (ggd x y) (iter (+ x 1) 1)))))
        
(iter 2 1)

스몰토크로 짠 구구단
~cpp 
PrintGugudan
	| a b |
	a := 2.
	b := 1.
	
	[ a <= 9 ] whileTrue: 
	[ 
		[ b <= 9] whileTrue: 
		[ 
				Transcript show: a; show: '*'; show: b; show: '='; show: a*b; cr.
			b := b + 1.
		].
		a := a + 1. 
		b := 1.
	].



Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2009-05-27 07:09:19
Processing time 0.1850 sec