- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我刚刚尝试了这个线性搜索
,结果发现它显示了else
部分。我不明白我做错了什么。逻辑...
#include<stdio.h>
#include<conio.h>
main()
{
int a[10], i, x, size;
printf("Enter the size of the array: \n");
scanf("%d",&size);
printf("Enter the elements into the array: \n");
for(i=0; i<size; i++)
{
scanf("%d",&a[i]);
}
printf("Enter the element to be searched for: \n");
scanf("%d",&x);
for(i=0; i<size; i++)
{
if(x==a[i])
{
printf("The element is at: %d",i);
break;
}
else
{
printf("The element is not in the array.");
break;
}
}
getch();
}
最佳答案
因为当它检查第一个元素并发现它不是您要查找的元素时,它就会跳出循环。
关于c - 为什么会跳到 `else`部分呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15174785/
如果我有一个使用 strpos() 导出的字符串位置,我将如何跳到该位置?我正在使用一个需要从该位置或下一行开始处开始的函数。 我该怎么做?速度是一个因素。 最佳答案 您可以使用 跳到字符串中的任何字
我构建了一个表单,用数组中的数据填充字段。 我有 2 个按钮,一个将使用 Ajax“发布”- 提交,另一个我试图跳到数组中的下一个对象 - 跳过。 我不知道如何让跳过按钮起作用。我有 found允许您
我实现了一个具有开始和结束状态的 CSS3 动画。一旦达到结束状态,动画就会停止并且不再重复。我需要做的是有一个绕过整个动画但显示最终状态的“跳到结束”链接。是否可以通过 CSS3 执行此操作。 这是
我有一个应用程序,我试图从 jQuery .animate 切换到 CSS3 转换,以响应滑动手势和按钮按下来左右移动卡片列表。 除了一件事,它现在运行良好。我希望该应用程序每次滑动一次移动一页卡片,
我下载了 Matchit 插件并将其用于我的 HTML 文件。一切都按预期工作,直到我在我的列表中使用它。 reddit vim w3schools 如果光标在第一个 o
我下载了 Matchit 插件并将其用于我的 HTML 文件。一切都按预期工作,直到我在我的列表中使用它。 reddit vim w3schools 如果光标在第一个 o
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 9 年前。 Improve
在我的 Scala 代码中的 for 循环中,如果特定条件为真,我想跳到循环的开头并且不执行以下语句。在 Java 中,我可以使用“继续”来执行此操作。但是“继续”在 Scala 中似乎不起作用。那么
我犯了一个错误,将 Visual Studio 项目从 2008 年升级到 2010 年,但没有先检查我以前的更改。因此,我有一个巨大的系统生成文件(10k+ 行),每 4 行更改一次。 我通常很擅长
#include #include int main() { char nameuser[12]; int userChoice; printf("Name(Max. 12 Chara
我正在使用 Firebase 存储上传文件。 https://firebase.google.com/docs/storage/web/upload-files#monitor_upload_prog
我有一个带有 TransitionListener 的 MotionLayout,我的 MotionScene 的进度似乎从 0 到 1:
大家好,我对 qprogressbar 有疑问。我怎样才能使它光滑?我希望它从 0 到 100% 顺利进行。我将它与 reply 变量一起使用,该变量从 php 脚本读取数据并返回给我数据。我需要等待
我有一个非常非常奇怪的问题,我无法弄清楚。所以你可以看看,这是我的代码; point * findLongPaths(point * points, double threshold_distance
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我正在播放一个电视节目,该节目已使用 AVQueuePlayer 在我的项目中分成不同的章节。我还想提供在 AVQueuePlayer 已经播放时跳到上一章/下一章或即时选择不同章节的可能性。 AVQ
我想在我的环境中设置这样的东西。 [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKe
这个问题已经有答案了: Identity increment is jumping in SQL Server database (6 个回答) 已关闭 8 年前。 我遇到了一个奇怪的情况,其中 SQ
当我进入循环时,我的“计数器”从 1 跳到 4。有任何想法吗?代码和输出如下: static bool harvestLog() { ifstream myFile("LOGS/ex0
我正在尝试解决所有关于 codility 的类(class),但我未能解决以下问题:Ladder by codility 我在整个互联网上进行了搜索,但没有找到令我满意的答案,因为没有人回答为什么最大
我是一名优秀的程序员,十分优秀!