登录 立即注册

首页 > 绿虎论坛 > 电脑 > 讨论/求助 (发帖)

标题: 组装台式电脑预算7500以内

作者: @Ta

时间: 2023-02-11发布,2023-02-11修改

点击: 56114

虎友推荐一下。
X86,给设计同事需要的
一加8Pro


[隐藏样式|查看源码]


『回复列表(10|显示机器人聊天)』

1. [s]因帖子修改,原回复作废。[/s]
(/@Ta/2023-02-11 19:25//)

2.
(/@Ta/2023-02-11 19:26//)

3. @罐子,内存换成两条16G,基本就够了,设计打游戏都可以
Screenshot_2023-02-12-21-56-11-756-edit_com.android.browser.jpg(438.74 KB)
(/@Ta/2023-02-12 21:56//)

4.

C:\Users\Admin\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
一加8Pro

(/@Ta/2023-02-17 13:11//)

5.

[email protected]
package main

//计算hex校验和
import (
"bufio"
"fmt"
"os"
"regexp"
"strconv"
"strings"
)

func main() {
fmt.Println("请输入要计算校验和的行:")
reader := bufio.NewReader(os.Stdin)
line, := reader.ReadString('\n')
line = strings.TrimSpace(line)
checksum,
:= strconv.ParseInt(line[len(line)-2:], 16, 64) //

pattern := regexp.MustCompile(`.{2}`)
parts := pattern.FindAllString(line[1:len(line)-2], -1)

var nums []int
for _, p := range parts {
    num, _ := strconv.ParseInt(p, 16, 64)
    nums = append(nums, int(num))
}
newChecksum := 256 - reduce(nums)
if checksum == int64(newChecksum) {
    fmt.Println("校验和匹配,该行无需修改")
} else {
    fmt.Printf("校验和不匹配,原校验和:%d,应该改为:%d\n", checksum, newChecksum)
    fmt.Println("正确的行:")
    fmt.Printf("%s%02X\n", line[:len(line)-2], newChecksum)
}

}
func reduce(nums []int) int {
return reduceHelper(nums, 0)
}
func reduceHelper(nums []int, acc int) int {
if len(nums) == 0 {
return acc % 256
}
return reduceHelper(nums[1:], (acc+nums[0])%256)
}

This is a program written in Go to calculate the checksum of a given hex line and compare it to the last two digits of the input line. The program takes input from the user, removes whitespace characters, and extracts the last two digits as the expected checksum. Then, it extracts pairs of hex digits (two characters) from the remaining part of the input line and converts them to integers. The reduce function is called with the resulting list of integers as an argument, which recursively sums them and takes the result modulo 256. The calculated checksum is then compared to the expected checksum, and if they match, the program outputs that the line is correct. Otherwise, the program outputs the correct checksum and the modified line with the correct checksum appended at the end.

[email protected]
package main

//计算hex校验和
import (
"bufio"
"fmt"
"os"
"regexp"
"strconv"
"strings"
)

func main() {
fmt.Println("请输入要计算校验和的行:")
reader := bufio.NewReader(os.Stdin)
line, := reader.ReadString('\n')
line = strings.TrimSpace(line)
checksum,
:= strconv.ParseInt(line[len(line)-2:], 16, 64) //

pattern := regexp.MustCompile(`.{2}`)
parts := pattern.FindAllString(line[1:len(line)-2], -1)

var nums []int
for _, p := range parts {
    num, _ := strconv.ParseInt(p, 16, 64)
    nums = append(nums, int(num))
}
newChecksum := 256 - reduce(nums)
if checksum == int64(newChecksum) {
    fmt.Println("校验和匹配,该行无需修改")
} else {
    fmt.Printf("校验和不匹配,原校验和:%d,应该改为:%d\n", checksum, newChecksum)
    fmt.Println("正确的行:")
    fmt.Printf("%s%02X\n", line[:len(line)-2], newChecksum)
}

}
func reduce(nums []int) int {
return reduceHelper(nums, 0)
}
func reduceHelper(nums []int, acc int) int {
if len(nums) == 0 {
return acc % 256
}
return reduceHelper(nums[1:], (acc+nums[0])%256)
}
改下添加按任意键退出
Sure, you can modify the code to add a prompt for the user to press any key to exit the program. You can use the function to wait for the user to input any text before exiting the program. Here's an example:fmt.Scanln()

go
Copy code
package main

import (
"bufio"
"fmt"
"os"
"regexp"
"strconv"
"strings"
)

func main() {
fmt.Println("请输入要计算校验和的行:")
reader := bufio.NewReader(os.Stdin)
line, := reader.ReadString('\n')
line = strings.TrimSpace(line)
checksum,
:= strconv.ParseInt(line[len(line)-2:], 16, 64)

pattern := regexp.MustCompile(`.{2}`)
parts := pattern.FindAllString(line[1:len(line)-2], -1)

var nums []int
for _, p := range parts {
    num, _ := strconv.ParseInt(p, 16, 64)
    nums = append(nums, int(num))
}
newChecksum := 256 - reduce(nums)
if checksum == int64(newChecksum) {
    fmt.Println("校验和匹配,该行无需修改")
} else {
    fmt.Printf("校验和不匹配,原校验和:%d,应该改为:%d\n", checksum, newChecksum)
    fmt.Println("正确的行:")
    fmt.Printf("%s%02X\n", line[:len(line)-2], newChecksum)
}
fmt.Println("按任意键退出...")
fmt.Scanln()

}

func reduce(nums []int) int {
return reduceHelper(nums, 0)
}

func reduceHelper(nums []int, acc int) int {
if len(nums) == 0 {
return acc % 256
}
return reduceHelper(nums[1:], (acc+nums[0])%256)
}
With this modification, the program will wait for the user to press any key before exiting.

[email protected]
fmt.Scanln()只能算是按回车键退出,不算是任意键退出
You are correct, waits for the user to input a complete line, which usually requires pressing the Enter key. If you want to wait for the user to press any key, you can use a platform-specific package like to read a single key without waiting for Enter to be pressed. Here's an example that uses this package to wait for the user to press any key:fmt.Scanln()github.com/eiannone/keyboard

go
Copy code
package main

import (
"bufio"
"fmt"
"os"
"regexp"
"strconv"
"strings"

"github.com/eiannone/keyboard"

)

func main() {
fmt.Println("请输入要计算校验和的行:")
reader := bufio.NewReader(os.Stdin)
line, := reader.ReadString('\n')
line = strings.TrimSpace(line)
checksum,
:= strconv.ParseInt(line[len(line)-2:], 16, 64)

pattern := regexp.MustCompile(`.{2}`)
parts := pattern.FindAllString(line[1:len(line)-2], -1)

var nums []int
for _, p := range parts {
    num, _ := strconv.ParseInt(p, 16, 64)
    nums = append(nums, int(num))
}
newChecksum := 256 - reduce(nums)
if checksum == int64(newChecksum) {
    fmt.Println("校验和匹配,该行无需修改")
} else {
    fmt.Printf("校验和不匹配,原校验和:%d,应该改为:%d\n", checksum, newChecksum)
    fmt.Println("正确的行:")
    fmt.Printf("%s%02X\n", line[:len(line)-2], newChecksum)
}
fmt.Println("按任意键退出...")
keyboard.GetSingleKey()

}

func reduce(nums []int) int {
return reduceHelper(nums, 0)
}

func reduceHelper(nums []int, acc int) int {
if len(nums) == 0 {
return acc % 256
}
return reduceHelper(nums[1:], (acc+nums[0])%256)
}
In this example, we use the function from the package to wait for the user to press any key before exiting. Note that this package may not work on all platforms, so you should check the documentation and test the program on the platforms you plan to use it on.GetSingleKey()github.com/eiannone/keyboard
一加8Pro

(/@Ta/2023-02-17 21:32//)

6. 哈哈,机械革命Pro笔记本 rtx4060+12代标压i7只要5999,品控差,但价格香啊
(/@Ta/2023-02-18 11:12//)

7. @hik,品控差+1,再也不想碰了。我买的机械革命笔记本已经返修2次了,即将迎来第三次返修,早就有问题了,一直没空!!!
(/@Ta/2023-02-18 14:20//)

8.
层主 @天蓝 于 2023-02-20 20:22 删除了该楼层。
(/@Ta/2023-02-20 20:21//
被锁定
)

11.

@天蓝,你的小尾巴误导了它

(/@Ta/2023-02-20 20:34//)

23. 过两天组装一台2000预算的台式
(/@Ta/2023-03-10 23:00//)

回复需要登录

11月23日 15:34 星期六

本站由hu60wap6华为CPU驱动

备案号: 京ICP备18041936号-1