구구 ¶
C++
~cpp
#include <iostream>
using namespace std;
int main()
{
for (int by=1 ; by<10 ; by++)
{
for (int i=2 ; i<6 ; i++)
cout << i << " * " << by << " = " << i*by << "\t";
cout << endl;
}
cout << endl;
for (by=1 ; by<10 ; by++)
{
for (int i=6 ; i<10 ; i++)
cout << i << " * " << by << " = " << i*by << "\t";
cout << endl;
}
return 0;
}
구구 ¶
Scheme - when
~cpp
(define (niner by plus) (when (< by 10)
(cond ((< plus 10) (begin (print by) (print *) (print plus) (print =) (print (* by plus)) (newline) (niner by (+ plus 1))))
((>= plus 10) (niner (+ by 1) 1))
)))
(niner 2 1)
Scheme - if
~cpp
(define (niner by plus)
(if (< by 10)
(cond ((< plus 10) (begin (print by) (print *) (print plus) (print =) (print (* by plus)) (newline) (niner by (+ plus 1))))
((>= plus 10) (niner (+ by 1) 1))
) (print "end") ))
(niner 2 1)
Squeak
- Niner
~cpp Object subclass: #NameOfSubclass instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Leonardong'
- Niner2to9
~cpp Niner2to9 | gob pp | gob:=2. pp:=1. 8 timesRepeat: [9 timesRepeat: [Transcript show: gob*pp;cr. pp := pp + 1.]. gob := gob + 1. pp := 1].
- workspace
~cpp niner := Niner new. niner Niner2to9.










