第一個(gè)的代碼如下,可以改變i的數(shù)值來控制X形狀的大小

創(chuàng)新互聯(lián)長(zhǎng)期為超過千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為費(fèi)縣企業(yè)提供專業(yè)的網(wǎng)站制作、網(wǎng)站設(shè)計(jì),費(fèi)縣網(wǎng)站改版等技術(shù)服務(wù)。擁有10余年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。
class Test
{
public static void main(String[] args)
{
int i=3;
int j=i*2-1;
int k,l;
for(;j0;j--)
{
k=(i-1)-Math.abs(j-i);
l=Math.abs(j-i)*2-1;
for(;k0;k--)
{
System.out.print(" ");
}
System.out.print("*");
if(l0)
{
for(;l0;l--)
{
System.out.print(" ");
}
System.out.print("*");
}
System.out.print("\n");
}
}
}
你第二個(gè)我也沒看明白,不過思路應(yīng)該都差不多,你根據(jù)這一個(gè)自己琢磨琢磨吧,關(guān)鍵問題就在k和l的計(jì)算上.
public class A {
public void drow(int n){//n表示高度(打印的行數(shù))
for(int i=n;i0;i--){
for(int j=i-1;j0;j--){//先打印i-1個(gè)空格
System.out.print(" ") ;
}
System.out.print("*") ;//打印第一個(gè)*
for(int j=2*(n-i)-1;j0;j--){//中間部分的空格
System.out.print(" ") ;
}
if(i!=ni!=1){//除了首尾兩行外每行中間的*
System.out.print("*") ;
}
for(int j=2*(i-1)-1;j0;j--){//右面部分的空格
System.out.print(" ") ;
}
System.out.println("*") ;//最后一個(gè)*
}
}
public static void main(String[] args){
A a = new A() ;
a.drow(3) ;//這里打印一個(gè)三層的
}
}
以下的代碼就可以,lz自己在*的地方填入星星的圖片就可以了
body bgcolor=#ee3300
style
.drop { position: absolute; width: 3; filter: flipV(), flipH(); font-size: 40; color: #ffffff }
/style
script language="javascript"
snow = false; // false-rain; true-snow
snowsym = " * " are the symbols for each
rainsym = " * " can put images here.
howmany = 20 many drops/snowflakes?
/**************Do not need to change anything below***********/
if(snow){sym = snowsym; speed=1; angle=10; drops=howmany}
else{sym = rainsym; speed=30; drops=howmany; angle=6}
movex = -speed/angle; movey = speed; count = 0;
function moverain(){
for(move = 0; move drops; move++){
xx[move]+=movex; yy[move]+=mv[move];
hmm = Math.round(Math.random()*1);
if(xx[move] 0){xx[move] = maxx+10;}
if(yy[move] maxy){yy[move] = 10;}
drop[move].left = xx[move]
drop[move].top = yy[move]+document.body.scrollTop;
}setTimeout('moverain()','1')}
/script
script language="javascript"
if (document.all){
drop = new Array(); xx = new Array(); yy = new Array(); mv = new Array()
ly = "document.all[\'"; st = "\'].style"
for(make = 0; make drops; make++){
document.write('div id="drop'+make+'" class=drop'+sym+'/div');
drop[make] = eval(ly+'drop'+make+st);
maxx = document.body.clientWidth-40
maxy = document.body.clientHeight-40
xx[make] = Math.random()*maxx;
yy[make] = -100-Math.random()*maxy;
drop[make].left = xx[make]
drop[make].top = yy[make]
mv[make] = (Math.random()*5)+speed/16;
drop[make].fontSize = (Math.random()*10)+20;
if(snow){col = 'white'}else{col = 'white'}
drop[make].color = col;
}
window.onload=moverain
}
/script
/body
package panel;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import javax.swing.JPanel;
import main.MainTank;
public class TipPanel extends JPanel implements Runnable{
/**
*
*/
private static final long serialVersionUID = 1L;
//偶數(shù)打印,畫面板
int time=0;
public void paintComponent(Graphics g){
super.paint(g);
g.fillRect(0, 0, MainTank.getWidthOfGame(), MainTank.getHeightOfGame());//繪制提示窗口
if (time%2==0){//偶數(shù)打印,畫面板,造成閃爍效果
g.setColor(Color.ORANGE);
Font font=new Font("華文楷體",Font.BOLD,30);
g.setFont(font);//選用字體
g.drawString("Ready", 140, 130);
}
}
@Override
public void run() {
while (true){
try{
Thread.sleep(250);
}catch (Exception e){
e.getMessage();
}
time++;//繪圖開關(guān)
this.repaint();
}
}
}//TipPanel
類似的,修改下就行
當(dāng)前標(biāo)題:java滿天星星代碼,HTML 滿天星代碼
網(wǎng)頁路徑:http://chinadenli.net/article33/dsegsss.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、軟件開發(fā)、營銷型網(wǎng)站建設(shè)、微信公眾號(hào)、標(biāo)簽優(yōu)化、ChatGPT
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)