- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我已经有一段时间没有用 C 编写任何程序了,所以我需要一些帮助。下面的代码有某种错误。当我运行代码时,if
和 else if
被跳过,屏幕上提示我的硬编码错误。
void play_tictactoe()
{
int row = 0, column = 0, i, win = 0;
char letter = 0;
char board[3][3] =
{
{' ',' ',' '},
{' ',' ',' '},
{' ',' ',' '}
};
printf( "\nDo you want to be X or O: " );
scanf( "%c", &letter );
if( letter == 'x' || letter == 'X' )
{
for( i = 0; i > 9 && win == 0; i++ )
{
printf( "\nPlace X: Row 1-3 and Column 1-3 (i.e. 1,3 for Row 1 and Column 3): " );
scanf( "%i,%i", &row, &column );
do
{
playersTurnX( &row, &column, board );
computersTurnX( &row, &column, board );
}
while( row > 3 || column > 3);
}
}
else if( letter == 'o' || letter == 'O' )
{
for( i = 0; i > 9 && win == 0; i++ )
{
printf( "\nPlace O: Row 1-3 and Column 1-3 (i.e. 1,3 for Row 1 and Column 3): " );
scanf( "%i,%i", &row, &column );
do
{
//computersTurnO( &row, &column, &board );
//playersTurnO( &row, &column, &board );
}
while( row > 3 || column > 3);
}
}
else
{
printf( "\nError!!!!\tInvalid entry.\n" );
}
}
最佳答案
当您使用时:
scanf( "%c", &letter );
你最终甚至将换行符读入 c
。使用:
scanf( " %c", &letter );
// ^^^^ add a space before %c.
使用 "%c"
将确保跳过所有空白字符,并且只有非空白字符将被读入 c
。
关于c - 错误 : maybe the else if statement?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32461626/
在 go lang 中使用“If with a short statement”有什么好处。引用:go tour if v := math.Pow(x, n); v < lim { retur
完全错误: Warning: Unsafe statement written to the binary log using statement format since BINLOG_FORMAT
完全错误: Warning: Unsafe statement written to the binary log using statement format since BINLOG_FORMAT
我有三个存储过程 Sp1、Sp2 和 Sp3。 第一个 (Sp1) 将执行第二个 (Sp2) 并将返回的数据保存到 @tempTB1 中,第二个将执行第三个 (Sp3) 并将数据保存到 @tempTB
我已将 FLAG 设置为 1,并且正在执行 ARG 值应该仅为 DEV。但是我得到的是 ARG= DEV + CLIENTID 000023 // FLAG=1 000026 // I
我已将 FLAG 设置为 1,并且正在执行 ARG 值应该仅为 DEV。但是我得到的是 ARG= DEV + CLIENTID 000023 // FLAG=1 000026 // I
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
PMD告诉我 A switch with less than 3 branches is inefficient, use a if statement instead. 这是为什么呢?为什么是3?他
我刚开始学习 Racket,所以我仍在努力弄清楚这门语言的复杂性。我正在尝试在列表中实现我自己的搜索功能。如果函数找到它,则返回索引,否则返回 -1。 (define (find-index list
在 Kotlin 中,您可以使用类似于三元运算符的 if 语句。 我们可以选择做这样的事情: val x = if (isOdd) 1 else 2 但是如果我们有多个变量需要根据某些条件进行设置,那
在我的 Android 应用程序中,我尝试使用 XMLPullParser 使用以下代码读取 xml 文件: while (eventType != XmlPullParser.END_DOCUMEN
这个问题已经有答案了: Boolean expressions in Java (8 个回答) 已关闭 7 年前。 我遇到过一些情况,其中第一个似乎改变了 boolean 值,而第二个却没有!两者之间
我基本上想做的是: select * from request where id = 1 and created_at like (today's date); 但使用 Eloquent 。 我试过:
我不确定为什么会收到此代码。基本上我希望能够动态定位我的发射器,但是当我添加一个选项来检查位置并根据需要进行纠正时,我不断收到此错误。 添加的代码是 if (
何时使用语句而不是准备语句。我想语句用于没有参数的查询,但为什么不使用准备好的语句呢?对于没有参数的查询,哪个更快。 最佳答案 I suppose statement is used in queri
我必须创建一个表,如下所示 借款人(客户编号,贷款编号) 如果客户没有超过 3 笔贷款,则可以贷款。 我创建的表如下 create table borrower( customerno int(5),
这个问题在这里已经有了答案: 关闭 12 年前。 Possible Duplicates: Is "else if" faster than "switch() case"? What is the
typescript 版本 2.2.2 我在我的 UserRoutzr.ts 中写了这个要求 const users = require(path.join(process.cwd() + "/da
我有一个用 JPQL 编写的应用程序,它可以命中非常不同的查询(在不同的资源上)。 对于很多此类查询,我需要知道结果总数(计数),因为我没有应用任何 LIMIT/OFFSET 由于此查询的性质非常不同
我对以下 Java 语句感到困惑: ArtClass artClass0 = new ArtClass(); int int3 = 73; boolean boolean0 = artClass0.f
我是一名优秀的程序员,十分优秀!