码:
#include <stdio.h>
main() {
int nums[100], i;
char answer;
int count = 0;
double avg;
for (i = 0; i < 100; i++) {
printf("Enter number %d: ", i + 1);
scanf("%d", &nums[i]);
printf("Another? ");
scanf("%c", &answer);
count += nums[i];
}
}
Run Code Online (Sandbox Code Playgroud)
跑:
~> a.out
Enter number 1: 1
Another? Enter number 2: 2
Another? Enter number 3: 3
Another? Enter number 4: 4
Another? Enter number 5: 5
Another? Enter number 6: 6
Another? Enter number 7: 7 …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个循环,以便用户可以输入一个数字,并在每个数字后提示他们是否要输入另一个数字.如果他们选择除了n或之外的任何东西N,那么计数就会增加,所以循环继续前进,但事实并非如此!
#include <stdio.h>
main() {
int nums[10], i, tot = 0;
int answer;
double avg;
int count = 1;
for (i = 0; i < count; i++) {
printf("Enter number %d: ", i + 1);
scanf("%d", &nums[i]);
printf("Enter another number? ");
scanf(" %c", &answer);
tot += nums[i];
if (answer != 78 && answer != 110) {
count++;
}
else { count = count - 1; }
printf("[c:%d][i:%d]", count, i);
}
}
Run Code Online (Sandbox Code Playgroud)
我得到的输出:
Enter number 1: 2 …Run Code Online (Sandbox Code Playgroud) 我正在制作一个id menu为具有以下设置的菜单:
display: inline;
height: 200px;
Run Code Online (Sandbox Code Playgroud)
一旦我移除display: inline;,身高再次起作用.
为什么?
老实说,不知道为什么这不起作用.我正在阅读针对Web开发人员的第三版专业JavaScript和尝试示例.在完成html标记之后,脚本不应该加载吗?
的index.html
<!DOCTYPE html>
<html>
<head>
<title>Example HTML Page</title>
<script type="test/javascript" defer src="js/example1.js"></script>
<script type="test/javascript" defer src="js/example2.js"></script>
<script type="text/javascript">
alert("test");
</script>
</head>
<body>
<h1> test </h2>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
JS/example1.js
alert("test");
Run Code Online (Sandbox Code Playgroud)
JS/example2.js
alert("test2");
Run Code Online (Sandbox Code Playgroud) 嘿,我有一个div content,我想加载外部html文件.当我点击导航中的链接时:
<div class="nav">
<div class="logo">
<strong>
<a href="index.html">
<img src="images/logo.png" alt="Sam Jarvis logo"/>
</a>
</strong>
</div>
<div class="menu">
<ul>
<li><a href="#home">HOME</a></li>
<li><a href="#about">ABOUT</a></li>
<li><a href="#work">PORTFOLIO</a></li>
<li><a href="#clients">CONTACT</a></li>
</ul>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我希望每个链接淡入一个外部html文件.如果我单击home,index.html将淡入.如果我单击另一页,则上一页淡出,新的页淡入.
我不确定为什么我当前的链接没有弹出警告框.如何在我的菜单ul中使用jQuery定位单个链接?
jQuery的:
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<!-- SCRIPTS -->
<script type="text/javascript">
$(document).ready(function(){
$(".menu ul li a").click(function(){
alert("Execute");
});
});
</script>
Run Code Online (Sandbox Code Playgroud) 我正在尝试这样做,但它不起作用:
$date = "on" date('l, F jS') "at" date('g:i:s A');
Run Code Online (Sandbox Code Playgroud)
这样就会输出:
on Day, Month 00th, at 0:00 PM
Run Code Online (Sandbox Code Playgroud)
(^当前日期)
文件
plym fury 77 73 2500
chevy nova 79 60 3000
ford mustang 65 45 17000
volvo gl 78 102 9850
ford ltd 83 15 10500
Chevy nova 80 50 3500
fiat 600 65 115 450
honda accord 81 30 6000
ford thundbd 84 10 17000
toyota tercel 82 180 750
chevy impala 65 85 1550
ford bronco 83 25 9525
Run Code Online (Sandbox Code Playgroud)
我必须删除10,000美元或更多的所有汽车(文件的最后一栏).我必须通过在记录结尾处表示代表5位或更多位的正则表达式时退出来将排序的输出传输到sed中.
这是我必须管道的命令: grep -iv chevy cars | sort -nk 5
我到目前为止尝试过:
grep -iv chevy cars | sort -nk 5 …
可能重复:
iostream和iostream.h之间的区别
我的教授说以下内容:
#include <iostream.h>
Run Code Online (Sandbox Code Playgroud)
是相同的:
#include <iostream>
using namespace std;
Run Code Online (Sandbox Code Playgroud)
我有点困惑.iostream和之间有什么区别iostream.h?
do {
cout << "Quantity : ";
cin >> sale->quantity;
cout << "Unit Price: ";
cin >> sale->unitPrice;
cout << "Taxable : ";
cin >> sale->taxStatus;
} while (sale->quantity != 0);
Run Code Online (Sandbox Code Playgroud)
当我进入0了quantity,但它仍然要求我要unitPrice和taxStatus,然后将其终止.一旦quantity输入,我怎么能让我的循环终止0?
编辑
> echo "" | a.out
Sale Records
=============
Quantity : Unit Price: Taxable : Quantity : Unit Price: Taxable : Quantity : Unit Price: Taxable : Quantity : Unit Price: Taxable : Quantity : Unit …Run Code Online (Sandbox Code Playgroud) 我一直在阅读粘性标题,这是我到目前为止所发现的.第一个粘性标题工作得很好但我怎么能滚动第一个标题并在遇到它时将第一个标题推出视图后使第二个标题卡住了?
<style>
body {
margin: 0;
text-align: center;
font-family: sans-serif;
}
.fixed {
position: fixed;
top: 0;
}
.sticky {
width: 100%;
background: #F6D565;
padding: 25px 0;
text-transform: uppercase;
}
</style>
<p style="margin-bottom:100px;">Scroll this page.</p>
<div class="sticky"><h3>Super amazing header</h3></div>
<p style="margin-top:500px;">Still there?</p>
<p style="margin-top:500px;">Yep!</p>
<p style="margin-top:500px;">Scroll so hard!</p>
<div class="sticky"><h3>Super amazing 123</h3></div>
<p style="margin-top:500px;">Still there?</p>
<p style="margin-top:500px;">Yep!</p>
<p style="margin-top:500px;">Scroll so hard!</p>
<script>
var sticky = document.querySelector('.sticky');
var origOffsetY = sticky.offsetTop;
function onScroll(e) {
window.scrollY >= origOffsetY ? sticky.classList.add('fixed') : …Run Code Online (Sandbox Code Playgroud) 我有一个文本区域,可以在其中粘贴一段 HTML 代码。当我点击提交时,我想从该块中提取所有 CSS 类和 ID,并将它们放入一个数组中。
到目前为止,我已经提交工作以及正则表达式,但我不知道如何过滤整个块并提取文本与正则表达式匹配的所有实例。
索引.html
<body>
<textarea id="codeInput"></textarea>
<button id="submitCode">submit</button>
<script src="functions.js"></script>
</body>
Run Code Online (Sandbox Code Playgroud)
函数.js
$(function() {
$('#submitCode').click(function() {
var codeInput = $('textarea#codeInput').val();
console.log(codeInput);
});
});
Run Code Online (Sandbox Code Playgroud)