我试图在我的C代码中进行while循环
像这样:
main()
{
char q ;
while( a == 'yes' )
{
/* my code */
printf("enter no to exit or yes to continue");
scanf("%s",q);
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我输入字符"q"....控制台崩溃了
并停止工作
我在while循环中错了什么?
我是C的初学者,我正在尝试编写一个矢量乘法代码.我读了一个数组和比例.然后我将此比例乘以数组中的每个元素.
for (i = 0 ; i < 5 ; i++)
{
scanf("%d", &numbers[i]);
}
puts("Please enter the scale:");
scanf("%d", s);
puts("The scaled vector is:");
for (j = 0 ; j < 5 ; j++)
{
int r = numbers[j] * s ;
printf("%d\n", r);
}
Run Code Online (Sandbox Code Playgroud)
但是,当我运行此代码时,我会收到以下输入的意外值:
1
2
3
4
5
Run Code Online (Sandbox Code Playgroud)
规模:
2
Run Code Online (Sandbox Code Playgroud)
输出:
6130616
12261232
18391848
24522464
30653080
Run Code Online (Sandbox Code Playgroud)
例如,当我用2 替换s
in时numbers[j] * s
,它将返回预期的输出.
我正在尝试使用HTML制作BMI计算器.输入来自文本字段.我在Javascript函数中用它们进行一些计算.我想在这样的范围内得到计算值:
<span id="" class="">Your Calculation Results is = </span>
<span id="" class=""> "" I want the result here "" </span>
Run Code Online (Sandbox Code Playgroud)
================================================== ==================编辑:我要问的部分
<script language="javascript">
var bmi = document.getElementById("ID_bmiResult2").innerHTML;
bmi.value = weight / (heightInMeter * heightInMeter);
</script>
<body>
<span id="ID_bmiResult2"> </span>
</body>
Run Code Online (Sandbox Code Playgroud)
我不知道怎么做...
我正在尝试dataGridView
使用数据库中的数据填充 a ,它必须在加载表单和refreshButton
单击时获取数据。
这是代码:
public partial class PhoneBookMainWindow : Form
{
static public string connString = "Server=(local); Database=PhoneBook; Trusted_Connection=TRUE";
public SqlConnection connection = new SqlConnection(connString);
private void btnRefreshPhoneBook_Click(object sender, EventArgs e)
{
SqlCommand command = new SqlCommand("SELECT ID, contactName, jobTitle, currentAddress, workAddress, workPhone, cellPhone FROM ContactsInformations", connection);
try
{
SqlDataAdapter dataAdapter = new SqlDataAdapter();
dataAdapter.SelectCommand = command;
DataTable dataSet = new DataTable();
dataAdapter.Fill(dataSet);
BindingSource bindingSrc = new BindingSource();
bindingSrc.DataSource = dataSet;
dataGridView1.DataSource = bindingSrc;
dataAdapter.Update(dataSet);
} …
Run Code Online (Sandbox Code Playgroud) 我有这个jquery代码
$(document).ready(function(){
$(".C_bmiShowTableWord").click(function () {
$(".C_bmiShowTable").slideDown();
});
});
Run Code Online (Sandbox Code Playgroud)
如果我点击C_bmiShowTableWord
它会滑下来C_bmiShowTable
如果我点击C_bmiShowTableWord
并且C_bmiShowTable
已经向下滑动,然后将其向上滑动,我想制作它...而且^ ^ ^
这个简单的程序输入整数并打印它们,但如果它看到60就停止打印
string input = string.Empty;
int intValue = 0;
int[] numbers = new int[5];
for (int i = 0; i < 4; i++)
{
input = Console.ReadLine();
if (int.TryParse(input, out intValue))
numbers[i] = intValue;
}
for (int i = 0; i < numbers.Length; i++)
{
while (numbers[i] != 60)
{
Console.WriteLine(intValue);
}
}
Run Code Online (Sandbox Code Playgroud)
程序在第4次输入之后继续进行无限循环输入:1 2 3 4 4 4 4 4 4 ........等等
我不知道原因.... ^ _ ^
代码
int cycle_length(int i, int j) {
int cycleLength = 0;
for (int k = i; k <= j; k++) {
cout << algorithm(k) << endl;
if (algorithm(k) > cycle_length) {
cycleLength = algorithm(k);
}
}
return cycleLength;
}
Run Code Online (Sandbox Code Playgroud)
ISO C++ forbids comparison between pointer and integer [-fpermissive]
我在这一行得到了这个错误if ( algorithm(k) > cycle_length)
.
然而,这是怎么回事main()
?什么是这个错误意味着???
添加 算法是一个取整数输入并返回整数的函数.
int algorithm(int number1) {
int counter = 1, number = number1;
do {
if (number % 2 == 0) { …
Run Code Online (Sandbox Code Playgroud) 我有许多函数将全局ArrayList作为参数,其中一些不对此列表进行任何更改,而其他函数需要在工作时删除此数组的某些元素,因此我在这些函数中创建了一个本地tempArrays.
static ArrayList array1 = new ArrayList();
public fn1(ArrayList array1)
{
ArrayList tempArray1 = new ArrayList();
tempArray1 = array1;
tempArray1.remove(elemnt);
}
Run Code Online (Sandbox Code Playgroud)
问题是删除的元素也从原始arrayList中删除array1
,我不知道为什么?.
谢谢..
c ×2
c# ×2
arraylist ×1
c++ ×1
datagridview ×1
html ×1
iso ×1
java ×1
javascript ×1
jquery ×1
scanf ×1
slidedown ×1
slideup ×1
while-loop ×1
winforms ×1