Skip to content
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

ring.rs 是否应该添加一个终止条件会更好 #13

Open
peanut-cc opened this issue Mar 4, 2022 · 2 comments
Open

ring.rs 是否应该添加一个终止条件会更好 #13

peanut-cc opened this issue Mar 4, 2022 · 2 comments

Comments

@peanut-cc
Copy link

当NUM - out 的值小于 COUNT的时候应该退出循环,这样最终如果加上打印ring的值可以更加直观的看到结果

if j == COUNT {
    println!("{} ----> out", i+1);
    out = out + 1;
    ring[i] = 0;
    j = 0;
    if NUM-out < COUNT {
        break;
    }
}
@limingth
Copy link
Contributor

limingth commented Mar 4, 2022 via email

@peanut-cc
Copy link
Author

现在的这个循环结束条件,最终打印ring ,里面所有的元素都已经更改为0,期望ring的不应该是这样子么:
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants