Xcode 帮助 (C) : 控制台消失并且没有输出
Xcode Help (C) : Console disappears and gives no output
我对 C 编程语言和一般编程还很陌生。我试图创建一个简单的程序,它从 99 开始,递减 3 直到 0。当整数可被 5 整除时,该程序还必须能够输出 "Found one!"。谢谢,任何帮助都值得赞赏!
#include <stdio.h>
int main(int argc, const char * argv[]) {
int i;
for (i = 100; i < -1; i -= 3) {
printf("%d\n", i);
if (i % 5 == 0) {
printf("Found one!\n");
}
}
return 0;
}
这应该适合你:
#include <stdio.h> //For printf function
#include <stdlib.h> //For system function
int main(int argc, char * argv[]) {
int i;
for (i = 99; i >= 0; i -= 3) {
//^^ ^^ Changed Condition
//|i assigned to 99
printf("%d\n", i);
if (i % 5 == 0 && i != 0) {
//^^^^^^^^^Also check that it's not true with 0
printf("Found one!\n");
}
}
system("pause");
return 0;
}
我对 C 编程语言和一般编程还很陌生。我试图创建一个简单的程序,它从 99 开始,递减 3 直到 0。当整数可被 5 整除时,该程序还必须能够输出 "Found one!"。谢谢,任何帮助都值得赞赏!
#include <stdio.h>
int main(int argc, const char * argv[]) {
int i;
for (i = 100; i < -1; i -= 3) {
printf("%d\n", i);
if (i % 5 == 0) {
printf("Found one!\n");
}
}
return 0;
}
这应该适合你:
#include <stdio.h> //For printf function
#include <stdlib.h> //For system function
int main(int argc, char * argv[]) {
int i;
for (i = 99; i >= 0; i -= 3) {
//^^ ^^ Changed Condition
//|i assigned to 99
printf("%d\n", i);
if (i % 5 == 0 && i != 0) {
//^^^^^^^^^Also check that it's not true with 0
printf("Found one!\n");
}
}
system("pause");
return 0;
}