Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarceloRosendo/6f6ed26c23dd91ee68c48351e7f3427c to your computer and use it in GitHub Desktop.
Save MarceloRosendo/6f6ed26c23dd91ee68c48351e7f3427c to your computer and use it in GitHub Desktop.
projeto de grafos aaplicando fluxo máximo
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/awesomeProject.iml" filepath="$PROJECT_DIR$/.idea/awesomeProject.iml" />
</modules>
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/grafos-tp2" vcs="Git" />
</component>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="00032597-7a21-43ed-867c-07410141fd42" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Go Application" />
</list>
</option>
</component>
<component name="GOROOT" path="C:\Users\marce\sdk\go1.13.4" />
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/grafos-tp2" />
</component>
<component name="ProjectId" id="1Tf4EFL1jvDkyA59jDTUyMU2vSx" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
<component name="PropertiesComponent">
<property name="DefaultGoTemplateProperty" value="Go Application" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="go.import.settings.migrated" value="true" />
<property name="last_opened_file_path" value="$USER_HOME$" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.path.for.package.eslint" value="project" />
<property name="node.js.path.for.package.tslint" value="project" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="nodejs_package_manager_path" value="npm" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="go build awesomeProject" type="GoApplicationRunConfiguration" factoryName="Go Application" temporary="true" nameIsGenerated="true">
<module name="awesomeProject" />
<working_directory value="$PROJECT_DIR$/" />
<kind value="PACKAGE" />
<filePath value="$PROJECT_DIR$/main.go" />
<package value="awesomeProject" />
<directory value="$PROJECT_DIR$/" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Go Build.go build awesomeProject" />
</list>
</recent_temporary>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
</project>
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func readEntry() (int64, int64, int64) {
scanner := bufio.NewScanner(os.Stdin)
for{
scanner.Scan()
in := scanner.Text()
parts := strings.Split(in, " ")
N, err := strconv.ParseInt(parts[0],10, 64)
if (err != nil || N < 2 || N > 50) {
fmt.Println("error:", err)
fmt.Println("enter a valid number:")
}
M, err := strconv.ParseInt(parts[1],10, 64)
if (err != nil || M < 1 || M > 2450 ){
fmt.Println("error",err)
fmt.Println("enter a valid number")
}
A, err := strconv.ParseInt(parts[2],10, 64)
if (err != nil || A < 1 || A > 50) {
fmt.Println("error",err)
fmt.Println("enter a valid number")
}
return N, M, A
}
}
func readEntryLine(N int64) (int64, int64, int64) {
scanner := bufio.NewScanner(os.Stdin)
for{
scanner.Scan()
in := scanner.Text()
parts := strings.Split(in, " ")
O, err := strconv.ParseInt(parts[0],10, 64)
if (err != nil || O < 1 || O > N) {
fmt.Println("error:", err)
fmt.Println("enter a valid number:")
}
D, err := strconv.ParseInt(parts[1],10, 64)
if (err != nil || (D < 1 || D > N) && O == D ){
fmt.Println("error",err)
fmt.Println("enter a valid number")
}
S, err := strconv.ParseInt(parts[2],10, 64)
if (err != nil || S < 1 || S > 50) {
fmt.Println("error", err)
fmt.Println("enter a valid number")
}
return O, D, S
}
}
func main(){
fmt.Println("enter with 3 numbers")
N, M, A := readEntry()
var O = make([]int64, M)
var D = make([]int64, M)
var S = make([]int64, M)
var i int64
for i = 0; i < M; i++ {
O[i], D[i],S[i] = readEntryLine(N)
}
fmt.Println("Aaaaaaaa", A)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment