✍️
Notes.md
  • Table of contents
  • React.Js
    • React Hooks
    • Old :- React : Using Classes
  • Blockchain
    • Solidity
    • Custom ERC20 token
    • Contract
  • Tools and Tech
    • Docker
    • Git version Control
  • Java
    • Data & Data Types
    • IO in Java
    • Data Structures
      • Array in Java
      • Collections in Java
      • Map in Java
      • Enums in Java
      • Linked List in Java
      • List in Java
      • Queues & Stacks
      • Set in Java
      • TreeSet and TreeMap
    • Object Oriented Programming
      • Object Class Methods and Constructor
      • Immutable Class & Objects
      • Constructors
      • Visibility
      • Generics
    • Threads in Java
    • Useful Stuff Java
      • Lambda & Stream
    • Keywords in Java
      • Annotations
      • Comparators
      • Packages in Java
    • Miscellaneous
    • Articles to refer to
  • Golang
    • Competitive Programming in Go
    • Testing simple web server
    • Learning Go : Part 1
    • Maps vs slices
    • Golang Garbage Collector 101
    • Things Golang do differently
    • Go Things
  • Linux
    • Shell programming
    • Linux Commands Part 1 - 4
    • Linux Commands Part 5 - 8
    • Linux Commands Part 9 - 10
  • Software Design
    • Solid Design
    • OOPS
    • Design Patterns
      • Creational Design Pattern
        • Builder DP
        • Factory DP
        • Singleton DP
      • Adapter DP
      • Bridge DP
      • Iterator DP
      • State DP
      • Strategy DP
      • Behavioral Design Pattern
        • Observer DP
      • Structural Design Pattern
        • Facade DP
  • Cloud
    • Google Cloud Platform
      • GCP Core Infrastructure
      • Cloud Networking
  • Spring Boot
    • Spring Basics
      • Spring Beans
      • Important Annotations
      • Important Spring Things
      • Maven Things
      • Spring A.O.P
    • Spring Boot Controller
      • Response Entity Exception Handling
    • Spring Things
    • Spring MVC
    • Spring Data
      • Redis
      • Spring Data JPA
      • JDBC
    • Apache Camel
  • Miscellaneous
    • Troubleshooting and Debugging
Powered by GitBook
On this page
  • Things to refer
  • Min/Max Int and Uint
  • 2d-vector-input.go
  • custom-vector-input.go
  • integer-input.go
  • map-slice.go
  • string-input.go
  • vector-input-integer.go

Was this helpful?

  1. Golang

Competitive Programming in Go

Its sweet

Things to refer

Min/Max Int and Uint

const MaxUint = ^uint(0)
const MinUint = 0

const MaxInt = int(^uint(0) >> 1)
const MinInt = -MaxInt - 1

2d-vector-input.go

package main

import (
    "fmt"
)

func main() {

    var cols, rows = 0, 0
    fmt.Print("Enter the number of cols : ")
    _, _ = fmt.Scan(&cols)
    fmt.Print("Enter the number of rows : ")
    _, _ = fmt.Scan(&rows)

    var twodslices = make([][]int, rows)
    var i int
    for i = range twodslices {
        twodslices[i] = make([]int, cols)
    }

    for i := 0; i < rows; i++ {
        for j:=0; j<cols; j++ {
            fmt.Scan(&twodslices[i][j])
        }
    }
    fmt.Println(twodslices)
}

custom-vector-input.go

package main

import (
    "fmt"
)

func main() {
    numberOfStrings := 0
    var vector []string
    _, _ = fmt.Scanln(&numberOfStrings)

    {
        var number string
        for i := 0; i < numberOfStrings; i++ {
            _, _ = fmt.Scanln(&number)
            vector = append(vector, number)
        }
    }

}

integer-input.go

package main

import "fmt"

func main() {
    var number int32
    _, _ = fmt.Scanf("%d", &number)
    fmt.Println(number)
}

map-slice.go

package main

import "fmt"

func main() {

    var elements = make([]map[string]string,1)
    elements[0] = map[string]string {
        "uday" : "uday",
    }

    fmt.Println(elements[0]["uday"])


}

string-input.go

package main

import (
    "bufio"
    "fmt"
    "os"
)

func main() {

    fmt.Print("Enter your full name : ")
    myString, _ := bufio.NewReader(os.Stdin).ReadString('\n')
    fmt.Print("myString : ", myString)

}

vector-input-integer.go

package main

import "fmt"

func main() {

    var number int
    _, _ = fmt.Scanln(&number)
    var vector = make([]int, number)
    for i := 0; i < number; i++ {
        _, _ = fmt.Scan(&vector[i])
    }
    fmt.Println(vector)
}
PreviousGolangNextTesting simple web server

Last updated 3 years ago

Was this helpful?