EUREKAR
Eurekar·TOP
捕捉真实世界的英语信号
24信息来源
13,843精选文章
168单词卡片
18照片图片
全部8,766口语2,186题库9,066免费1,238帖子4,786新闻6,579外刊291Books4Cards168图片18

Thread 109396994

主题帖 109396994

4chan /g/ · Anonymous · 2026-07-28 23:18 · 39 帖 · 原文 ↗

← 上一篇返回列表下一篇 →
#1 Thread 109396994 / 主题帖 109396994
Anonymous · 2026-07-28 23:18

(无正文)

图片: https://i.4cdn.org/g/1785280695736442.png

↳ #2 No.109397076
Anonymous · 2026-07-28 23:30

>>109396994

i asked claude and it failed. this question isn't possible.

我问了 Claude,它搞不定。这个问题无解。

↳ #3 No.109397100
Anonymous · 2026-07-28 23:33

#include <limits.h>

#include <限制.h>

unsigned int length_of_longest_char_sequence(char *str, char c)

无符号整型 最长字符序列长度(字符指针 str, 字符 c)

{

unsigned int count = 0;

无符号整数计数 = 0;

unsigned int count_max = 0;

无符号整数 count_max = 0;

if (str) {

如果(字符串){

for (unsigned int i = 0; i < UINT_MAX && str[i]; ++i) {

for (无符号 int i = 0; i < UINT_MAX && str[i]; ++i) {

if (str[i] == c) {

如果 (str[i] == c) {

++count;

if (count_max < count) count_max = count;

如果 (count_max < count),则将 count_max 设置为 count;

} else {

} 别的 {

count = 0;

计数=0;

}

}

}

return count_max;

返回 count_max;

}

↳ #4 No.109397136
Anonymous · 2026-07-28 23:37

>>109397100

Couldn't a string be longer than UINT_MAX?

字符串的长度不可能超过 UINT_MAX 吗?

↳ #5 No.109397142
Anonymous · 2026-07-28 23:38

>>109397100

>unsigned int instead of unsigned long or size_t

>用 unsigned int 而不用 unsigned long 或 size_t

Get a load of this dalit.

瞧瞧这个贱民。

↳ #6 No.109397178
Anonymous · 2026-07-28 23:43

>>109396994

Sir, please listen.

先生,请听我说。

Dennis Ritchie created C language in early 1970s.

丹尼斯·里奇在70年代初创造了C语言。

No Google. No Stack Overflow. No GitHub. No AI. No Claude. No Cursor. No Codex.

没有Google。没有Stack Overflow。没有GitHub。没有AI。没有Claude。没有Cursor。没有Codex。

Zero, sir. Completely zero.

零,先生。完全是零。

- No venture capitalist uncle giving 2 crore for 2% equity.

- 没有那个给2%股权出2千万卢比的风险投资叔叔。

- No "product launch" with 50 YouTubers.

- 没有带着50个YouTuber的“产品发布会”。

- No TED Talk where he walks slowly from left to right.

- 没有那种他在台上从左走到右的TED演讲。

Sir, only two engineers at Bell Labs.

先生,贝尔实验室当时只有两个工程师。

Ek terminal.

一台终端。

And ek problem—"Sir, yeh Unix thoda slow ho raha hai."

然后出了一个bug——“先生,Unix有点慢。”

Dennis Ritchie sir ne language likhi.

Dennis Ritchie先生写了这门语言。

Size? Sir, kilobytes main fit ho gayi.

规模?先生,它只占几KB。

Aaj ek WhatsApp forward 10 MB ka aata hai.

今天一个WhatsApp转发消息都有10MB大。

50 years later, sir –

50年后,先生——

- Linux kernel.

- Linux内核。

- Windows.

- 窗户。

- macOS.

- macOS系统。

- Every iPhone.

- 每一部iPhone。

- Every Android.

- 每一部Android手机。

- NASA ke deep space probes.

- NASA的深空探测器。

International Space Station—sir, wahan bhi C hai.

国际空间站——先生,那儿也有C语言。

Python borrowed from it, sir. Java borrowed, with full respect. JavaScript borrowed, sir—without permission also.

Python向它借鉴,先生。Java向它借鉴,满怀敬意。JavaScript也向它借鉴,先生——连 permission(许可)都没要。

Sir, if you have ever written a single line of code in any language, even "Hello World" in college lab, you did it in Dennis Ritchie's shadow.

先生,如果你曾在任何语言里写过一行代码,哪怕只是大学机房里的“Hello World”,那你也是在Dennis Ritchie的阴影下完成的。

No shortcut. No tutorial. No "Bhaiya ek doubt hai."

没有捷径。没有教程。没有“兄弟,我有个疑问”。

And sir, he died in 2011. Same week as Steve Jobs. Steve Jobs got front pages. Covers. Special memorial. Sir, even Tribute Comments on LinkedIn.

而且先生,他在2011年去世了。和Steve Jobs同一周。Steve Jobs占据了头版。封面。特别纪念。先生,LinkedIn上全是致敬评论。

Ritchie sir got silence. Ekdum pindrop silence. Crickets sound, sir.

Ritchie先生得到的却是沉默。绝对的死寂。连蟋蟀叫声都听得见,先生。

Sir, this legend deserves celebration. No hype. No arrogance. No "break the internet." But without him, no internet to break, sir.

先生,这位传奇值得庆祝。没有炒作。没有傲慢。没有“炸翻互联网”。但如果没有他,先生,根本就没有什么互联网可以炸。

Dennis Ritchie sir – we salute you.

Dennis Ritchie先生——向您致敬。

Ek plate samosa and chai for the OG, please.

请给这位OG(元老)端上一盘萨莫萨和茶。

↳ #7 No.109397189
Anonymous · 2026-07-28 23:44

>>109397142

>t.

图片: https://i.4cdn.org/g/1785282283864905.png

↳ #8 No.109397219
Anonymous · 2026-07-28 23:47

>>109397178

>Steve Jobs got front pages. Covers. Special memorial.

>Steve Jobs占据了头版。封面。特别纪念。

>Sir, even Tribute Comments on LinkedIn.

>先生,LinkedIn上全是致敬评论。

Thanks for this laugh bloody benchod

谢谢你这该死的逗乐,混球(benchod)

↳ #9 No.109397274
Anonymous · 2026-07-28 23:54

>>109397100

i suppose a driver program would be helpful, too

我想还需要一个驱动程序吧

#include <stdio.h>

这看起来是一个代码片段,而不是论坛帖子或对话内容。请重新发送需要翻译的中文或英文文本。

int main(int argc, char *argv[])

int main(int argc, char *argv[])(C 代码:带参数的主函数)

{

if (argc < 3) {

如果 (argc < 3) {

printf("USAGE:\n\t%s <str> <char>\n", argv[0]);

printf("用法:\n\t%s <字符串> <字符>\n", argv[0]);

return -1;

返回-1;

}

char *str = argv[1];

char *str = argv[1];(C 代码:取第一个命令行参数)

char c = argv[2][0];

char c = argv[2][0];(C 代码:取第二个参数的首字符)

unsigned int i = length_of_longest_char_sequence(str, c);

无符号 int i = length_of_longest_char_sequence(str, c);

printf("str=%s\nc=%c\ni=%i\n\n", str, c, i);

printf("str=%s\nc=%c\ni=%i\n\n", str, c, i);(C 代码:格式化输出三个值)

return 0;

返回 0;

}

>>109397136

it is not possible to have a string of infinite length

不可能存在无限长的字符串

>>109397142

size_t was a mistake.

size_t 是个错误。

↳ #10 No.109397348
Anonymous · 2026-07-29 00:07

>>109397178

kek, nice prompt for your actually indian

哈哈,给你这真正印度风的提示打满分

↳ #11 No.109397410
Anonymous · 2026-07-29 00:15

holy shit, i got the 100 point menu

哇靠,我拿到了满分菜单

i think the poll pushed me over the edge

我觉得是那个投票把我逼疯了

图片: https://i.4cdn.org/g/1785284133133632.png

↳ #12 No.109399432
Anonymous · 2026-07-29 05:59

>>109397274

>it is not possible to have a string of infinite length

>不可能存在无限长的字符串

So what happens if I make a string in c that's longer than UINT_MAX? Will I get a compiler error? Do I need to have some string splitting algo?

那我如果造一个在C语言里比UINT_MAX还长的字符串会怎样?编译器会报错吗?我需要搞个字符串分割算法吗?

↳ #13 No.109399576
Anonymous · 2026-07-29 06:31

>>109399432

the program as it stands would return before getting to the null terminator

目前的程序会在到达空终止符之前就返回

this implies it can't detect a run equal to or longer than UINT_MAX.

这意味着它无法检测等于或长于UINT_MAX的连续字符序列。

accepting that limitation, there's nothing wrong with the program, and it will compile and return without issue.

接受这个局限性的话,程序本身没毛病,能正常编译并返回,不会出问题。

using size_t would allow the possibility handling c strings up to the maximum size allowed by the system. this is really the proper type to use, but gets a little annoying sometimes.

使用 size_t 允许处理最长可达系统允许最大尺寸的C字符串。这其实是正确的类型,但有时候挺烦人的。

↳ #14 No.109400186
Anonymous · 2026-07-29 08:55

>>109396994

Please give me strength Ritchie-sama. I am but a humble retard.

请赐予我力量,Ritchie大人。我只是一个卑微的渣渣。

func challenge(c rune, r string) int {

函数挑战(c 字符, r 字符串) 整数 {

var best int = 0

var 最佳整数 = 0

var cur int = 0

var 当前整数 = 0

for _, cc := range r {

对于 r 中的每个 cc,执行以下操作:

if cc == c {

cur++

} else {

} 别的 {

best = max(best, cur)

最佳值 = max(最佳值, 当前值)

cur = 0

当前 = 0

}

}

return max(best, cur)

返回最大值(最佳,当前)

}

↳ #15 No.109400799
Anonymous · 2026-07-29 11:05

a much more interesting algorithm problem is to determine the m-th largest number in an array of N numbers

一个更有趣的算法问题是:在 N 个数的数组中找出第 m 大的数

↳ #16 No.109401600
Anonymous · 2026-07-29 13:47

>>109400799

man 3 qsort

人 3 排序

↳ #17 No.109401733
Anonymous · 2026-07-29 14:09

max(find(diff[0 str == c 0] == -1) - find(diff[0 str == c 0] == 1))

max(find(diff[0 str == c 0] == -1) - find(diff[0 str == c 0] == 1))(MATLAB 代码:找最长不匹配区间)

There's also a function that can do this:

还有个函数能做到这一点:

sum(bwareafilt(str == c, 1))

sum(bwareafilt(str == c, 1))(MATLAB 代码:二值图像区域统计)

↳ #18 No.109401923
Anonymous · 2026-07-29 14:34

>>109396994

who needs an algorithm when you can use an existing function

既然有现成的函数,谁还需要算法呢

↳ #19 No.109405093
Anonymous · 2026-07-29 21:13

>>109401600

terrible space usage and time complexity for the problem you are trying to solve, not a good algorithm to use in this case

空间占用和时间复杂度对于你要解决的问题来说都很糟糕,这种情况下这不是个好算法

↳ #20 No.109405103
Anonymous · 2026-07-29 21:14

>>109401733

>There's also a function that can do this:

>还有个函数能做到这一点:

yeah, i wrote it in the second post

是的,我在二楼的回复里写了

length_of_longest_char_sequence(str, c)

最长字符序列的长度(str,c)

↳ #21 No.109405182
Anonymous · 2026-07-29 21:24

>>109396994

odin can be quite comfy sometimes.

Odin(编程语言)有时候真的挺舒服的。

long_seq :: proc(c: rune, s: string) -> (l: int) {

long_seq :: proc(c: rune, s: string) -> (l: int) {(Odin 代码:查找最长连续字符序列的函数)

l = 0

lc := 0

for rune in s {

对于 s 中的符文 {

if rune == c {

如果 rune == c {

lc += 1

l = max(l, lc)

l = 最大值(l, lc)

} else {

} 别的 {

lc = 0

}

}

return

}

↳ #22 No.109405339
Anonymous · 2026-07-29 21:43

>>109397178

why dont you just speak one language at a time, poopkings?

你们这些屎王能不能一次只说一门语言?

↳ #23 No.109405509
Anonymous · 2026-07-29 22:05

>>109405182

>rune

what's odin's rune definition? grapheme?

Odin 的 rune 是怎么定义的?是字素(grapheme)吗?

i recently worked on font shaping for a graphics project and in graphical contexts, grapheme segmentation rerquires having gsub tables for the fonts you're using in order to segment codepoints into graphems (glyphs)

我最近在做一个图形项目的字体 shaping,在图形环境下,字素分割需要你所用字体具备 gsub 表,才能将代码点分割成字素(glyph)

↳ #24 No.109405513
Anonymous · 2026-07-29 22:06

>>109396994

i dont know how to code

我不会写代码

↳ #25 No.109408380
Anonymous · 2026-07-30 08:02

>>109396994

i showed you my code, were's dennis?

我展示了我的代码,Dennis 在哪?

↳ #26 No.109408488
Anonymous · 2026-07-30 08:35

>>109396994

size_t count_seq(char *s, char c) {

这段内容看起来是C语言代码,而非论坛帖子。请提供需要翻译的英文论坛内容。

if (!s) {

return 0;

返回 0;

}

size_t len = 0;

size_t 长度 = 0;

while (*s) {

当 (*s) 不为空时 {

size_t n = 0;

大小_t n = 0;

for (; *s++ == c; n++);

对于 (; *s++ == c; n++);

if (n > len) {

如果(n>长度){

len = n;

长度 = n;

}

}

return len;

返回长度;

}

↳ #27 No.109408582
Anonymous · 2026-07-30 09:02

>>109408488

Wouldn't it be smarter to just initiate len and remove the if?

直接初始化 len 然后删掉 if 判断不是更聪明吗?

↳ #28 No.109408659
Anonymous · 2026-07-30 09:21

size_t foo(int *arr, size_t n) {

这个函数定义看起来像是C语言的代码片段,但您没有提供需要翻译的文本内容。请提供具体的英文论坛帖子内容。

size_t max, tem;

size_t 最大值,温度;

int cur;

int 当前;

if (!n)

return 0;

返回 0;

max = tem = 1;

最大值 = TEM = 1;

cur = arr[0];

当前 = arr[0];

for (size_t i = 1; i < n; ++i) {

对于 (size_t i = 1; i < n; ++i) {

if (arr[i] != cur)

如果 (arr[i] != cur)

tem = 0, cur = arr[i];

tem 设为 0,cur 从 arr[i] 开始。

max = ++tem > max ? tem : max;

最大值 = ++tem > 最大值?温度:最大;

}

return max;

返回最大值;

}

c arrays cannot have more elements than can be represented by size_t

C 数组的元素数量不能超过 size_t 能表示的范围

↳ #29 No.109408683
Anonymous · 2026-07-30 09:28

>>109408659

just noticed everyone else is solving for a provided character, not any character

刚注意到其他人都在找给定字符,而不是找任何字符

↳ #30 No.109408756
Anonymous · 2026-07-30 09:48

>>109408582

You mean the early return at the top? That's meant to catch a null s before trying to dereference it in the while block. Removing that would require wrapping the rest of the function in an if block, like if (s) { ... } .

你是指开头的提前返回?那是为了在 while 块尝试解引用之前捕获空指针 s。去掉它的话,就得把函数其余部分包裹在 if 块里,比如 if (s) { ... } 。

↳ #31 No.109408777
Anonymous · 2026-07-30 09:53

>>109408756

I thought while (*s) would catch it too

我以为 while (*s) 也能处理掉这个情况

↳ #32 No.109408958
Anonymous · 2026-07-30 10:34

>>109408777

No, that instantly dereferences the pointer to check the value, which would cause a segfault if s is null. The purpose of that check is to see if *s, character pointed to by s, is the '\0' character.

不,那会立即解引用指针来检查值,如果 s 是空指针就会导致段错误。那个检查的目的是看看 *s(s 指向的字符)是不是 '\0' 字符。

↳ #33 No.109408963
Anonymous · 2026-07-30 10:35

>>109408958

>instantly

*immediately

↳ #34 No.109409206
Anonymous · 2026-07-30 11:33

>>109408958

Makes sense, I thought while was just smart enough not to run when it's given null

有道理,我以为 while 足够聪明,在收到空指针时不会运行

↳ #35 No.109410003
Anonymous · 2026-07-30 14:02

>>109396994

wtf is a linker

链接器(linker)是个啥玩意儿

↳ #36 No.109410009
Anonymous · 2026-07-30 14:03

>>109410003

It's what I did to your mom last night.

它是我昨晚对你妈干的事。

↳ #37 No.109410305
Anonymous · 2026-07-30 14:52

#include <stdio.h>

这看起来是一个代码片段,而不是论坛帖子或对话内容。请重新发送需要翻译的中文或英文文本。

int main(void) {

int 主函数(无效){

int char_count = 0;

int char_count = 0;(C 代码:字符计数器清零)

char mychar;

查我查;

char our_string[50];

定义一个名为our_string的字符数组,容量为50。

printf("Enter character: ");

printf("请输入字符:");

scanf("%c", &mychar);

scanf("%c", &mychar);(C 代码:读入一个字符)

printf("\t Enter our string: ");

printf("\t 输入我们的字符串: ");

scanf("%49s", &our_string);

scanf("%49s", &our_string);(C 代码:读入最长 49 字符的字符串)

//check if mychar is in our_string

//检查mychar是否在our_string中

for mychar in our_string...

遍历 our_string 中的每个字符...

}

curse you zybooks for making me so wimpy

去死吧 zybooks,害我变得这么弱鸡

图片: https://i.4cdn.org/g/1785423177431153.png

↳ #38 No.109410517
Anonymous · 2026-07-30 15:25

>>109410305

here, take mine

拿去,用我的

we can share

我们可以共享

#include "stdio.h"

这一行是C语言中的头文件包含语句,意思是引入标准输入输出库。

//first arg is the char, the second is the string

//第一个参数是字符,第二个是字符串

int main(int ac, char **av)

int main(int ac, char av)(C 代码:带参数的主函数)

{

if (ac != 3)

return (1);

返回(1);

char *current = av[2];

char *当前= av[2];

char target = *(av[1]);

字符目标 = *(av[1]);

int old_count = 0;

int 旧次数 = 0;

int new_count = 0;

新的计数 = 0;

while (*current)

当 (*current)

{

if (*current == target)

如果 (*current == 目标)

{

new_count++;

if (new_count > old_count)

if (新计数 > 旧计数)

old_count = new_count;

旧计数=新计数;

}

else

new_count = 0;

新计数 = 0;

current++;

}

printf("hngh : %d\n", old_count);

printf("嗯哼:%d\n", old_count);

return (0);

返回(0);

}

↳ #39 No.109413573
Anonymous · 2026-07-30 22:39

cheers ritch

干杯 ritch

#include <stdio.h>

这看起来是一个代码片段,而不是论坛帖子或对话内容。请重新发送需要翻译的中文或英文文本。

int main(int argc, char *argv[])

int main(int argc, char *argv[])(C 代码:带参数的主函数)

{

if (argc < 3) {

如果 (argc < 3) {

fprintf(stderr, "do: %s [string] [char]\n", argv[0]);

fprintf(stderr, "do: %s [字符串] [字符]\n", argv[0]);

return 1;

返回 1;

}

int longest = 0, count = 0, ch = *argv[2];

int 最长 = 0,计数 = 0,ch = *argv[2];

char *str = argv[1];

char *str = argv[1];(C 代码:取第一个命令行参数)

while (*str) {

而(*str){

if (ch == *str++) count++;

如果 (ch == *str++) count++;

else count = 0;

否则 count = 0;

if (count > longest) longest = count;

if (计数 > 最长) 最长 = 计数;

}

printf("longest sequence of '%c' in %s is %d\n", ch, argv[1], longest);

printf("在 %s 中找到字符 '%c' 的最长连续序列长度为 %d\n", ch, argv[1], longest);

return 0;

返回 0;

}

← 上一篇返回列表下一篇 →

(如果你觉得这篇文章有启发,可以点击这里付费)