-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added lab №8 #602
Open
moreqqq
wants to merge
3
commits into
ISUCT:Morev_Dmitrii
Choose a base branch
from
moreqqq:laba8
base: Morev_Dmitrii
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
added lab №8 #602
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,13 @@ | ||
package laba8 | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
func CreateFile(filename string) (string, error) { | ||
_, _ = os.Stat(filePath + filename) | ||
f, _ := os.Create(filePath + filename) | ||
|
||
defer f.Close() | ||
return filename, nil | ||
} |
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,10 @@ | ||
7.2 | ||
4.2 | ||
1.81 | ||
5.31 | ||
0.7 | ||
2.4 | ||
2.8 | ||
3.9 | ||
4.7 | ||
3.16 |
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 laba8 | ||
|
||
import ( | ||
"bufio" | ||
"os" | ||
) | ||
|
||
func ReadDataFromFile(filename string) []string { | ||
var textSlice []string | ||
f, _ := os.OpenFile(filePath+filename, os.O_RDONLY, 0600) | ||
defer f.Close() | ||
fileScanner := bufio.NewScanner(f) | ||
for fileScanner.Scan() { | ||
textSlice = append(textSlice, fileScanner.Text()) | ||
} | ||
|
||
return textSlice | ||
} |
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,15 @@ | ||
package laba8 | ||
|
||
func SearchingString(filename, valueForSearch string) (int, bool) { | ||
if valueForSearch == "" { | ||
return 0, false | ||
} | ||
values := ReadDataFromFile(filename) | ||
|
||
for _, value := range values { | ||
if value == valueForSearch { | ||
return 1, true | ||
} | ||
} | ||
return 0, false | ||
} |
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 laba8 | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func WriteDataToFile(filename string) { | ||
f, _ := os.OpenFile(filePath+filename, os.O_WRONLY, 0600) | ||
defer f.Close() | ||
var name string | ||
fmt.Scan(&name) | ||
var surname string | ||
fmt.Scan(&surname) | ||
|
||
f.WriteString(name) | ||
f.WriteString(surname) | ||
} |
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,34 @@ | ||
package laba8 | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
var filePath string = "../golang/laba8/" | ||
|
||
func RunLab8() { | ||
var filename string | ||
fmt.Println("Введите имя файла, в который вы хотите записать данные:") | ||
fmt.Scan(&filename) | ||
name, _ := CreateFile(filename) | ||
|
||
fmt.Println("Введите данные в файл (для завершения ввода введите q):") | ||
WriteDataToFile(name) | ||
|
||
slice := ReadDataFromFile(name) | ||
|
||
fmt.Printf("Чтение файла %s завершено\n", filename) | ||
for _, str := range slice { | ||
fmt.Println(str) | ||
} | ||
|
||
fmt.Println("Введите строку, которую хотите найти в файле: ") | ||
var StringForFind string | ||
fmt.Scan(&StringForFind) | ||
n, _ := SearchingString(name, StringForFind) | ||
if n == 1 { | ||
fmt.Printf("Слово найденно на строке %d", n) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тут всегда 1 строка выглядит странно |
||
} else { | ||
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,52 @@ | ||
package laba8 | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"os" | ||
"strconv" | ||
|
||
"isuct.ru/informatics2022/laba4" | ||
) | ||
|
||
func ReadDataFromFileForLab4(filename string) ([]float64, error) { | ||
f, err := os.Open(filePath + filename) | ||
fmt.Println(err) | ||
if err != nil { | ||
return nil, fmt.Errorf("ошибка открытия файла") | ||
} | ||
fileScanner := bufio.NewScanner(f) | ||
var values []float64 | ||
for fileScanner.Scan() { | ||
chislo, err := strconv.ParseFloat(fileScanner.Text(), 64) | ||
if err != nil { | ||
return nil, fmt.Errorf("ошибка при переводе числа") | ||
} | ||
values = append(values, chislo) | ||
} | ||
return values, nil | ||
} | ||
|
||
func RunLab8forLab4() { | ||
values, _ := ReadDataFromFileForLab4("Input.txt") | ||
|
||
var a float64 = values[0] | ||
var b float64 = values[1] | ||
var taskBslice = values[5:] | ||
fmt.Println("Задача А") | ||
var xn float64 = values[2] | ||
var xk float64 = values[3] | ||
var deltax float64 = values[4] | ||
for _, pair := range laba4.TaskA(a, b, xn, xk, deltax) { | ||
x := pair[0] | ||
y := pair[1] | ||
fmt.Printf("x = %.2f\ty = %f\n", x, y) | ||
} | ||
fmt.Println() | ||
fmt.Println("Задание B") | ||
for _, pair := range laba4.TaskB(a, b, taskBslice) { | ||
x := pair[0] | ||
y := pair[1] | ||
fmt.Printf("x = %.2f\ty = %f\n", x, y) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,16 +1,14 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"isuct.ru/informatics2022/laba4" | ||
"isuct.ru/informatics2022/laba6" | ||
"isuct.ru/informatics2022/laba7" | ||
"isuct.ru/informatics2022/laba8" | ||
) | ||
|
||
func main() { | ||
fmt.Println("Морев Дмитрий Михайлович") | ||
laba4.Runlab4() | ||
laba6.Runlaba6() | ||
laba7.RunLaba7() | ||
// fmt.Println("Морев Дмитрий Михайлович") | ||
// laba4.Runlab4() | ||
// laba6.Runlaba6() | ||
// laba7.RunLaba7() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. вернуть |
||
laba8.RunLab8forLab4() | ||
laba8.RunLab8() | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно только bool возвращать без n и проверять его же