CS50 Pset1(现金)编译错误
CS50 Pset1 (Cash) Compile Bug
我编写了整个 pset1(现金)代码,在 IDE 交换之前它工作得很好,但现在,使用新的 VSCode + CS50 IDE 我认为也许check50 和 submit50 命令有问题。
当我通过终端编译代码时它再次正常工作,但是当我检查它时我收到这条消息:
":( cash.c 编译
代码编译失败
这是我的代码,具有新的 pset1 页面要求:
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
int change;
do
{
change = get_int("Change: ");
}
while(change < 0);
if(change == 0)
{
printf("You'll need 0 coins!\n");
}
else
{
int c = change;
int x = 0;
while(c >= 25)
{
c -= 25;
x++;
}
while(c >= 10)
{
c -= 10;
x++;
}
while(c >= 5)
{
c -= 5;
x++;
}
while(c >= 1)
{
c -= 1;
x++;
}
printf("You'll need at least %i coins!\n", x);
}
}
这是我使用旧 pset1 要求的代码:
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
float change;
do
{
change = get_float("Change: ");
}
while(change < 0);
if(change == 0)
{
printf("You'll need 0 coins!\n");
}
else
{
int c = round(change * 100);
int x = 0;
while(c >= 25)
{
c -= 25;
x++;
}
while(c >= 10)
{
c -= 10;
x++;
}
while(c >= 5)
{
c -= 5;
x++;
}
while(c >= 1)
{
c -= 1;
x++;
}
printf("You'll need at least %i coins!\n", x);
}
}
IDE 并不是 2022 年发生的唯一变化。上面发布的代码不 满足“新”要求。确保您使用的是 2022 courseware. From the spec for cash
CS50x 2022’s version of Cash is quite different than CS50x 2021’s version. It will be in your best interest to do this problem from scratch, if you do not have credit for the work you did in 2021. Last year’s version will fail to compile when checked by check50
due to the fact that in this new version, you must implement functions which the testing suite will test independently, beyond just checking for the final answer (as last year’s version did).
我编写了整个 pset1(现金)代码,在 IDE 交换之前它工作得很好,但现在,使用新的 VSCode + CS50 IDE 我认为也许check50 和 submit50 命令有问题。
当我通过终端编译代码时它再次正常工作,但是当我检查它时我收到这条消息:
":( cash.c 编译 代码编译失败
这是我的代码,具有新的 pset1 页面要求:
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
int change;
do
{
change = get_int("Change: ");
}
while(change < 0);
if(change == 0)
{
printf("You'll need 0 coins!\n");
}
else
{
int c = change;
int x = 0;
while(c >= 25)
{
c -= 25;
x++;
}
while(c >= 10)
{
c -= 10;
x++;
}
while(c >= 5)
{
c -= 5;
x++;
}
while(c >= 1)
{
c -= 1;
x++;
}
printf("You'll need at least %i coins!\n", x);
}
}
这是我使用旧 pset1 要求的代码:
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
float change;
do
{
change = get_float("Change: ");
}
while(change < 0);
if(change == 0)
{
printf("You'll need 0 coins!\n");
}
else
{
int c = round(change * 100);
int x = 0;
while(c >= 25)
{
c -= 25;
x++;
}
while(c >= 10)
{
c -= 10;
x++;
}
while(c >= 5)
{
c -= 5;
x++;
}
while(c >= 1)
{
c -= 1;
x++;
}
printf("You'll need at least %i coins!\n", x);
}
}
IDE 并不是 2022 年发生的唯一变化。上面发布的代码不 满足“新”要求。确保您使用的是 2022 courseware. From the spec for cash
CS50x 2022’s version of Cash is quite different than CS50x 2021’s version. It will be in your best interest to do this problem from scratch, if you do not have credit for the work you did in 2021. Last year’s version will fail to compile when checked by
check50
due to the fact that in this new version, you must implement functions which the testing suite will test independently, beyond just checking for the final answer (as last year’s version did).