-
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
f0dbdbe
commit 6bf9b73
Showing
6 changed files
with
133 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,35 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
var ddd int | ||
|
||
fmt.Scan(&ddd) | ||
fmt.Println(GetDDD(ddd)) | ||
|
||
} | ||
|
||
func GetDDD(ddd int) string { | ||
|
||
switch ddd { | ||
case 61: | ||
return "Brasilia" | ||
case 71: | ||
return "Salvador" | ||
case 11: | ||
return "Sao Paulo" | ||
case 21: | ||
return "Rio de Janeiro" | ||
case 32: | ||
return "Juiz de Fora" | ||
case 19: | ||
return "Campinas" | ||
case 27: | ||
return "Vitoria" | ||
case 31: | ||
return "Belo Horizonte" | ||
default: | ||
return "DDD nao cadastrado" | ||
} | ||
} |
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,17 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
var entrada float64 | ||
positivos := 0 | ||
|
||
for i := 0; i < 6; i++ { | ||
fmt.Scan(&entrada) | ||
if entrada > 0 { | ||
positivos++ | ||
} | ||
} | ||
|
||
fmt.Printf("%d valores positivos\n", positivos) | ||
} |
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,20 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
var entrada, soma float64 | ||
positivos := 0 | ||
|
||
soma = 0.0 | ||
for i := 0; i < 6; i++ { | ||
fmt.Scan(&entrada) | ||
if entrada > 0 { | ||
positivos++ | ||
soma += entrada | ||
} | ||
} | ||
|
||
fmt.Printf("%d valores positivos\n", positivos) | ||
fmt.Printf("%.1f\n", soma/float64(positivos)) | ||
} |
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() { | ||
var entrada int | ||
pares := 0 | ||
|
||
for i := 0; i < 5; i++ { | ||
fmt.Scan(&entrada) | ||
|
||
if entrada%2 == 0 { | ||
pares++ | ||
} | ||
} | ||
|
||
fmt.Printf("%d valores pares\n", pares) | ||
} |
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() { | ||
var in int | ||
fmt.Scan(&in) | ||
|
||
if in%2 == 0 { | ||
in++ | ||
} | ||
|
||
fmt.Println(in) | ||
for i := 0; i < 5; i++ { | ||
in += 2 | ||
fmt.Println(in) | ||
} | ||
} |
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 main() { | ||
var x, y, soma int64 | ||
fmt.Scan(&x) | ||
fmt.Scan(&y) | ||
|
||
if x > y { | ||
temp := x | ||
x = y | ||
y = temp | ||
} | ||
x++ | ||
for i := x; i < y; i++ { | ||
if uint64(i)%2 == 1 { | ||
soma += i | ||
} | ||
} | ||
|
||
fmt.Println(soma) | ||
} |