几天前我刚刚开始学习 C 编程,我正在尝试从 Kattis (open.kattis.com) 网站上找到一些问题。一路上我想出了这个问题,但我并不真正理解它的含义。
//two stones
#include <stdio.h>
int main()
{
int n,x=2;
printf("The number of stones placed on the ground is ");
scanf("%d",&n);
if (n%x != 0)
{
printf("The winner of the game is Alice! \n");
}
else
{
printf("The winner of the game is Bob! \n");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这出现了>>
警告:忽略 scanf 的返回值,使用属性 warn_unused_result [-Wunused-result] 声明关于 scanf("%d",&n);
谁能解释这有什么问题以及如何纠正这个问题?谢谢。
所以我刚刚开始学习数组,并遇到了一个问题,要求我打印出A,A +,A-等字母的输出.
但是,我不确定如何将+或 - 符号输入到数组中.这是我的阵列线:
char letter_grade[12] = {'F','D',"D+",'C',"C+","B-",'B',"B+","A-",'A',"A+",'\0'};
Run Code Online (Sandbox Code Playgroud)
当我编译代码时出现这个警告:警告:指向整数转换的不兼容指针使用'char [3]'[-Wint-conversion]类型的表达式初始化'char'
任何人都可以帮助我改进我构建这个部分的方式,以便不出现警告吗?谢谢.