思科软件问题求助,Ctrl+Break中Break键电脑没有,我电脑没有小键盘 break键可以用其他键代替吗
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了思科软件问题求助,Ctrl+Break中Break键电脑没有,我电脑没有小键盘 break键可以用其他键代替吗相关的知识,希望对你有一定的参考价值。
YS-RouteSim_Cracked软件中有如下语句,
switch>;按Ctrl+Break键
switch:reset ;或用boot命令
其中的按Ctrl+Break键 我电脑没有Break这个键是不是不能用这个软件了啊
我是初学者,请多多指教
不行的话可以用系统自带的屏幕键盘,在附件的辅助工具里。 参考技术A 一定有的,你好好找找,一般是和pause这个键一起的 参考技术B 神舟电脑ctrl+c也可以,同样效果
摆脱程序中的break语句
【中文标题】摆脱程序中的break语句【英文标题】:Getting rid of break statement in program 【发布时间】:2018-04-10 06:14:21 【问题描述】:基本上,我的程序从随机数生成器中获取一个随机数,并计算通过该确切数字与另一个随机生成的数字(内部循环)匹配所需的次数。然后它进行计数并将其添加到总和中。然后外循环运行 50 次。我的问题是我的教授不想在程序中使用goto
或break
语句。这是我的第一门计算机编程课程,我不太确定如何更改程序以删除 break 语句并使其按应有的方式工作。该程序使用break
语句可以100% 正常工作。提前感谢您的帮助!
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
int main()
int randNumA = 0; int randNumB = 0; int i = 0.0;
int iterationa = 0; int iterationb = 0;
float avgIteration = 0.0;
int sumIteration = 0;
srand(time(NULL));
for(i = 0; i < 50; i++)
int randNumB = rand() % 100;
printf("The random number selected is %d\n", randNumB);
int iterationb = 0;
while (1)
int randNumA = rand() % 100;
if (randNumA < randNumB)
iterationa++;
iterationb++;
else if(randNumA > randNumB)
iterationa++;
iterationb++;
else
iterationa++;
iterationb++;
printf("The final iteration was %d\n\n", iterationb);
break;
sumIteration = sumIteration + iterationa;
avgIteration = (float)sumIteration / (float)50;
printf("The average amount of iterations for each attempt were %f\n",
avgIteration);
return 0;
【问题讨论】:
i = 50;
应该这样做。
它应该去哪里,@Nik?
我错过了嵌套的while
循环。这个建议行不通。你需要按照@ifconfig 的建议去做,除了bool
之外,使用int
,因为C
中没有bool
这样的东西
谢谢,@Nik 我忘了。习惯了 C++.... :)
或者,如果您在 while 循环上方声明 randNumA
,您也可以这样做:while (randNumA != randNumB)
。这可能是最简单的。
【参考方案1】:
这是对您的问题的另一种看法,清理了各种错误。 主要变化:
-
多次声明变量:即
int randNumA
while 循环不必要地复杂。参见 cmets。
简化的变量声明。
查看代码中的 cmets:
int main()
//It's great that you're initializing your variables.
//You can do it as a comma separated list as such.
int randNumA = -1,//so it definitely goes into the while loop the first time
randNumB = 0, i = 0, iterationa = 0, iterationb = 0, sumIteration = 0;
float avgIteration = 0;
srand(time(NULL));
for(i=0; i < 50; i++)
randNumB = rand() % 100;//You've already declared, don't need int in front
printf("The random number selected is %d\n", randNumB);
iterationb = 0;
while (randNumA != randNumB)//this will break the loop as is required
randNumA = rand() % 100;
//next two lines occur in all three conditions, so bring them outside
iterationa++;
iterationb++;
//No need for all three cases. Either equal or not!
if (randNumA == randNumB)
printf("The final iteration was %d\n\n", iterationb);
sumIteration += iterationa;//shorthand notation
avgIteration = (float)sumIteration / 50;//casing one of these will suffice
printf("The average amount of iterations for each attempt were %f\n", avgIteration);
return 0;
【讨论】:
【参考方案2】:检查,它是否按照您的意愿行事。如果需要,我可以添加 cmets。
我不使用您的一些变量,因为它们在这里是不必要的,而且还添加了几个新变量 - cnt
(while 循环的迭代计数器),num_iteration
(迭代次数),而不是文字 50
的数字。
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
float sum_iteration = 0;
int num_iteration = 50;
int cnt, i;
int rand_num_a = 0;
int rand_num_b = 0;
srand(time(NULL));
for(i = 0; i < num_iteration; i++)
rand_num_a = rand() % 100;
printf("The random number selected is %d\n", rand_num_a);
cnt = 0;
do
rand_num_b = rand() % 100;
cnt++;
while(rand_num_a != rand_num_b);
printf("The final iteration was %d\n\n", cnt);
sum_iteration += cnt;
printf("The average amount of iterations for each attempt were %f\n", sum_iteration / num_iteration);
return 0;
输出
The random number selected is 39
The final iteration was 71
The random number selected is 55
The final iteration was 119
The random number selected is 25
The final iteration was 10
... skip lines
The random number selected is 81
The final iteration was 132
The random number selected is 37
The final iteration was 300
The random number selected is 22
The final iteration was 19
The average amount of iterations for each attempt were 89.580002
【讨论】:
【参考方案3】:在顶部,您可以声明一个条件变量:int isNumNeither = 0;
,在 while 循环条件中检查该变量是否为 false,然后在 else
块中将其设置为 1
。
下次循环检查条件时,循环将自动退出,因为条件评估为假。
例如:
while (isNumNeither == 0)
int randNumA = rand() % 100;
if (randNumA < randNumB)
iterationa++;
iterationb++;
else if(randNumA > randNumB)
iterationa++;
iterationb++;
else
iterationa++;
iterationb++;
printf("The final iteration was %d\n\n", iterationb);
isNumNeither = 1;
【讨论】:
你的意思是while (isNumNeither == 0)
?以上是关于思科软件问题求助,Ctrl+Break中Break键电脑没有,我电脑没有小键盘 break键可以用其他键代替吗的主要内容,如果未能解决你的问题,请参考以下文章
如果一个程序是由 system() 或 CreateProcess() 从另一个程序启动的,如何防止 Ctrl+Break/Ctrl+C 关闭这两个程序?
continue与break 布尔值 整体注释:ctrl+?