데블스캠프 첫쨋날 구구단 코드.
처음 짠 코드
~cpp
#include<iostream>
using namespace std;
int main()
{
for(int i=1; i<10 ; i++)
{
for(int j=2; j<6; j++)
{
cout<<j<<"*"<<i<<"="<<j*i<<"\t";
}
cout<<endl;
;
}
cout<<endl;
for(int d=1; d<10 ; d++)
{
for(int k=6; k<10; k++)
{
cout<<k<<"*"<<d<<"="<<k*d<<"\t";
}
cout<<endl;
}
return 0;
}
데블스캠프 세째날 ¶
Squeak
~cpp
Object subclass: #Gugudan
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'cho'
~cpp
printGugudan
| x y |
x := 2.
y := 1.
8 timesRepeat: [9 timesRepeat: [ Transcript show:x*y; cr. y := y + 1. ]. x := x + 1. y := 1 ].
~cpp
gugudan := Gugudan new.
gugudan printGugudan.
~cpp
(define (inter x y)
( when (< x 10)
(if (= y 10)
(begin (inter (+ x 1) 1) )
(begin (print x)(print *)(print y)(print =)(print (* x y))(newline) (inter x (+ y 1)) )
)
)
)
(inter 2 1)