我的代码是为了打印反向的数组,但由于某种原因,如预期的那样减运算符不能正常工作.根据我的理解--var,var在完成操作之前递减变量,然后在完成操作(例如循环)之后var--递减变量.varfor
这是我的代码:
#include <iostream>
int main() {
int arrLen;
int arr[4];
scanf("%d\n %d %d %d %d", &arrLen, &arr[0], &arr[1], &arr[2], &arr[3]);
for (; arrLen >= 0; --arrLen)
printf("%d %d\n", arr[arrLen], arrLen);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是我的结果(输出中的正确值是递减的变量,我添加它来检查):
0 4
2 3
3 2
4 1
1 0
Run Code Online (Sandbox Code Playgroud)
如果没有打印的递减变量,它应该是:
0 2 3 4 1
以下是我的预期结果:
2 3 4 1
我最近开始学习jQuery并且遇到了一些问题.由于我来自C/C++背景,jQuery的代码格式不熟悉.
所以,我的问题是.append()似乎没有附加.我最近一直在编写一个脚本来在jQuery中创建一个弹出窗口,并且需要向body添加一个元素.没啥事儿.进一步测试后,.append()似乎没有用.我的结论是我可能会滥用它,但我不知道如何.
$('#contact').click(function (e) {
$('#about').append('<h1>test</h1>');
e.preventDefault();
});
Run Code Online (Sandbox Code Playgroud)
编辑1:请求了Html
<!DOCTYPE html>
<html>
<head>
<title>Canteen Mate</title>
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/css?family=Roboto">
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/css?family=Roboto+Condensed">
<link rel="stylesheet" type="text/css"
href="https://fonts.googleapis.com/css?family=Ubuntu">
<link rel="stylesheet" type="text/css" href="css/home.css">
</head>
<body>
<div class = "nav_wrapper" id = "nav_wrapper">
<nav>
<ul>
<li class = "current"><a href="#nav_wrapper" id = "Home" class = "nav">Home</a></li>
<li><a href="#about" id = "About" class = "nav">About</a></li>
<li><a href="#contact" id = "Contact" class = "nav">Contact</a> </li>
</ul>
</nav>
</div>
<div class = "wrapper">
<img src="images/newfood.jpg" alt="Food" …Run Code Online (Sandbox Code Playgroud)