cs50 - 值之间的差异以及代码如何读取 CS50 中的值
问题描述
这是我的主要代码:
// Update vote totals given a new vote
bool vote(string name, int candidatecount, candidate candidates1[MAX])
{
// TODO
for (int a = 0; a < candidatecount; a++)
{
if (candidatecount == a)
{
printf("a\n");
return false;
}
if (name == candidates1[a].names)
{
printf("b\n");
candidates[a].votes = candidates[a].votes + 1;
}
printf("%s, %s\n", candidates1[a].names, name);
}
printf("1\n");
return(name);
}
这是我的命令行:
./plurality R D
输出(我的回答)是这样的:
Number of voters: 3
Vote: R
R, R
D, R
1
Vote: D
R, D
D, D
1
Vote: R
R, R
D, R
1
vote candidate 0 go around 0
b 0 e (null)
vote candidate 0 go around 1
b 0 e (null)
(null) won with 0 votes.
它使它看起来像这样:
if (name == candidates1[a].names)
应该工作,但它没有,因为它之后的 printf 不起作用。有谁知道为什么?
解决方案
推荐阅读
- pine-script - 我无法访问此 pine 脚本警报,我无法解决此问题,请解决此问题
- azure-functions - 从 github 操作部署的 Azure 函数导致“错误:无法获取 Kudu 应用程序设置。错误请求(代码:400)”
- angular - 如何将异步数据作为输入属性角度传递?
- android - Android Google Assistant 呼叫操作
- python - `ColumnTransformer.fit_transform()` 的结果只包含后来的transfromer的结果
- python - 如何找到文件中的最大小数位数?
- c++ - 将字体添加到 QT C++
- javascript - 防止图像飞出窗外
- cakephp - 在控制器中对模拟对象使用期望的最佳实践是什么
- php - 查看存储在域文件夹之外的文档