首頁 文章 练习代码1

练习代码1

2022-09-27 11:52  瀏覽數:712  來源:小键人8966053    

package test;
public class IfElseTest {
public static void main(String[] args) {
int a = 3;
if (a == 1)
System.out.println("123");
else if (a == 2)
System.out.println("456");
else if (a == 3)
System.out.println("789");
else
System.out.println("qwe");
}
}
package test;
public class IfTest {
public static void main(String[] args) {
int a = 10;
int b = 8;
int max = a;
if (a < b) {
max = b;
}
System.out.println("123" + max);
}
}
package test;
public class SwitchTest {
public static void main(String[] args) {
int a = 2;
switch (a) {
case 1:
System.out.println("111");
case 2:
System.out.println("222");
case 3:
System.out.println("333");
case 4:
System.out.println("444");
default:
System.out.println("555");
}
}
}
package test;
// WhileTest.java
public class WhileTest {
public static void main(String[] args) {
int i = 0;
int sum = 0;
while (i <= 100) {
sum = sum + i;
i++;
}
System.out.println(sum);
}
}
package test;
public class DoWhileTest {
public static void main(String[] args) {
int i = 1;
do {
if (i % 2 == 0)
System.out.println(i + " ");
i++;
} while (i <= 20);
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>1234567890</title>
<link href="20.css" rel="stylesheet" type="text/css">
<style>
#ghost{height:264px;padding-left:70px}
</style>
<script>
var y=20;var n=10;
function b1(){
y=y+1;
document.getElementById("yes").innerHTML=y;
document.getElementById("py").value=y;
}
function b2(){
n=n+1;
no.innerHTML=n;
document.getElementById("pn").value=n;
}
</script>
</head>
<body>
<div id="container">
<div id="left">
<div id="weather">
<h3><span>123</span></h3>
<ul>
<li>123&nbsp;&nbsp;123</li>
<li>123&nbsp;&nbsp;123</li>
</ul>
<br>
</div>
</div>
<div id="middle">
<div id="toupiao">
<p>1234567890</p>
<p><button onclick="b1()">123</button>
<span id="yes">20</span><progress id="py" max=50 value="20"></progress></p>
<p>
<button onclick="b2()">123</button>
123<span id="no">10</span>
<progress id="pn" max=50 value="10"></progress>
</p>
</div>
</div>
<div id="right">
<div id="map">
<h3><span>1234567890/span></h3>
<p><a href="#" title="123"><img src="map1.jpg"></a></p>
<p><a href="#" title="123"><img src="map2.jpg"></a></p>
</div>
</div>
<div id="footer">
<p>1234567890<a href="mailto:demo@demo.com">demo@demo.com</a></p>
</div>
</div>
</body>
</html>



聲明:以上文章均為用戶自行添加,僅供打字交流使用,不代表本站觀點,本站不承擔任何法律責任,特此聲明!如果有侵犯到您的權利,請及時聯系我們刪除。

字符:    改为:
去打字就可以设置个性皮肤啦!(O ^ ~ ^ O)