-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3815972
commit 6f4b389
Showing
7 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func main() { | ||
stdin := bufio.NewReader(os.Stdin) | ||
for { | ||
fmt.Println("입력하세요.") | ||
var number int | ||
_, err := fmt.Scanln(&number) | ||
if err != nil { | ||
fmt.Println("숫자를 입력하세요.") | ||
|
||
stdin.ReadString('\n') | ||
continue | ||
} | ||
fmt.Printf("입력하신 숫자는 %d 입니다.\n", number) | ||
if number%2 == 0 { | ||
break | ||
} | ||
} | ||
fmt.Println("for문이 종료됐습니다.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
for i := 0; i < 3; i++ { | ||
for j := 0; j < 5; j++ { | ||
fmt.Print("*") | ||
} | ||
fmt.Println() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
for i := 0; i < 5; i++ { | ||
for j := 0; j < i+1; j++ { | ||
fmt.Print("*") | ||
} | ||
fmt.Println() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
dan := 2 | ||
b := 1 | ||
for { | ||
for { | ||
fmt.Printf("%d * %d = %d\n", dan, b, dan*b) | ||
b++ | ||
if b == 10 { | ||
break | ||
} | ||
} | ||
b = 1 | ||
dan++ | ||
if dan == 10 { | ||
break | ||
} | ||
} | ||
fmt.Println("for문이 종료되었습니다.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
a := 1 | ||
b := 1 | ||
found := false | ||
for ; a <= 9; a++ { | ||
for b = 1; b <= 9; b++ { | ||
if a*b == 45 { | ||
found = true | ||
break | ||
} | ||
} | ||
if found { | ||
break | ||
} | ||
} | ||
fmt.Printf("%d * %d = %d\n", a, b, a*b) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
a := 1 | ||
b := 1 | ||
|
||
OuterFor: | ||
for ; a <= 9; a++ { | ||
for b = 1; b <= 9; b++ { | ||
if a*b == 45 { | ||
break OuterFor | ||
} | ||
} | ||
} | ||
fmt.Printf("%d * %d = %d\n", a, b, a*b) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func find45(a int) (int, bool) { | ||
for b := 1; b <= 9; b++ { | ||
if a*b == 45 { | ||
return b, true | ||
} | ||
} | ||
return 0, false | ||
} | ||
|
||
func main() { | ||
a := 1 | ||
b := 0 | ||
|
||
for ; a <= 9; a++ { | ||
var found bool | ||
if b, found = find45(a); found { | ||
break | ||
} | ||
} | ||
fmt.Printf("%d * %d = %d\n", a, b, a*b) | ||
} |