把如下代碼加入body區(qū)域中
創(chuàng)新互聯(lián)公司主要從事成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)裕安,十多年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):028-86922220
style type="text/css"
body
{
background-color:#FFFFFF;
font-family: Arial;
font-size:10pt;
}
/style
script
text=new Array('www','njcatv','net','需要放大的
/\/\
\ /
\/
文字')
var numText=4
color=new Array('#000000','#2F2F2F','#4F4F4F','#7F7F7F','#408080')
var numColors=5
var endSize=70
var Zspeed=30
var Cspeed=200
var font='Arial Black'
var hide=false
var size=10
var gonum=0
var ie, n;
if (document.all) {
n=0
ie=1
zoomText='document.all.zoom.innerText=text[num]'
zoomSize='document.all.zoom.style.fontSize=size'
closeIt=""
fadeColor="document.all.zoom.style.color=color[num]"
}
if (document.layers) {
n=1;ie=0
zoomText=""
zoomSize="document.zoom.document.write('p align=\"center\" style=\"font-family:'+font+'; font-size:'+size+'px; color:'+color[0]+'\"'+text[num]+'/p')"
closeIt="document.zoom.document.close()"
fadeColor="document.zoom.document.write('p align=\"center\" style=\"font-family:'+font+'; font-size:'+endSize+'px; color:'+color[num]+'\"'+text[numText-1]+'/p')"
}
function zoom(num,fn){
if (sizeendSize){
eval(zoomText)
eval(zoomSize)
eval(closeIt)
size+=5;
setTimeout("zoom("+num+",'"+fn+"')",Zspeed)
}else{
eval(fn);
}
}
function fadeIt(num){
if (numnumColors){
eval(fadeColor)
eval(closeIt)
num+=1;
setTimeout("fadeIt("+num+")",Cspeed)
}else{
hideIt()
}
}
function hideIt(){
if(hide){
if(ie)document.all.zoom.style.visibility="hidden"
if(n)document.layers.zoom.visibility="hidden"
}
}
function init(){
if(ie){
document.all.zoom.style.color=color[0]
document.all.zoom.style.fontFamily=font
}
if(ie || n) go(0)
}
function go(num){
gonum+=1
size=10
if(numnumText){
zoom(num,'go('+gonum+')')
}else{
fadeIt(0)
}
}
/script
div id="zoom" align="center" style="position:absolute; top:150"
分析:
1.首先愛心分成兩半前面三行左右一樣右邊就可以通過(guò)左邊反相得到
中間兩行是個(gè)長(zhǎng)方形,剩下的就是個(gè)倒等腰三角形
2.在或者,長(zhǎng)得不太像- -
System.out.println(" ** **");
for (int i = 4; i 10; i++) {
for (int a = 0; a i; a++) {
System.out.print(" ");
}
for (int b = 1; b = 2 * 9 - 2 * i - 1; b++) {
System.out.print("*");
}
System.out.print("\n");
}
** **
*********
*******
*****
***
*
用java代碼輸出心的形狀
public class CartesianCurve extends Applet{
int width, height;
Image image;
Graphics draw_Curve;
public void init(){
setBackground(Color.black);
this.setSize(350, 310);
width = getSize().width;
height = getSize().height;
image = createImage(width, height);
draw_Curve = image.getGraphics();
}
public void paint(Graphics g){
draw_Curve.clearRect(0, 0, width, height);
draw_Curve.setColor(Color.red);
int i, j;
double x, y, r;
for(i = 0; i = 90; i++)
for(j = 0; j = 90; j++){
r = Math.PI / 45 * i * (1 - Math.sin(Math.PI / 45 * j)) * 18;
x = r * Math.cos(Math.PI / 45 * j) * Math.sin(Math.PI / 45 * i) + width / 2;
y = -r * Math.sin(Math.PI / 45 * j) + height / 4;
draw_Curve.fillOval((int) x, (int)y, 2, 2);
}
g.drawImage(image, 0, 0, this);
}
}
1,首先用圖紙畫一個(gè)心形。
2,使用方框,把每筆,做成一個(gè)點(diǎn)。
3,輸出這些點(diǎn)。就可以了。
希望能幫到你
用方程的話肯定輸出不會(huì)和你的圖完全一致
心形線方程如圖
用上面行第二個(gè)比較簡(jiǎn)單,程序如下
#include?stdio.h
bool?draw(float?x,?float?y)
{
float?a?=?x?*?x?+?y?*?y?-?1.0;
float?b?=?x?*?x?*?y?*?y?*?y;
return?a?*?a?*?a?-?b?=?0;
}
int?main(int?argc,?char*?argv[])
{
for?(float?y?=?1.5;?y?=?-1.5;?y?-=?0.1)
{
for?(float?x?=?-1.2;?x?=?1.2;?x?+=?0.05)
{
if?(draw(x,?y))
{
bool?left?=?draw(x?-?0.05,?y);
bool?right?=?draw(x?+?0.05,?y);
bool?up?=?draw(x,?y?+?0.1);
bool?down?=?draw(x,?y?-?0.1);
if?(left??right??up??down)
printf("?");
else
printf("*");
}
else
printf("?");
}
printf("\n");
}
return?0;
}
draw函數(shù)是判斷(x,y)坐標(biāo)是否在心形范圍內(nèi)
主函數(shù)循環(huán),y取值±1.5之間,步長(zhǎng)0.1,x取值±1.2之間,步長(zhǎng)0.05
如果(x,y)坐標(biāo)在心形范圍外打印空格
如果(x,y)坐標(biāo)在心形范圍內(nèi),由于這個(gè)心是空心的,要繼續(xù)判斷是不是心形邊緣,判斷周圍4個(gè)點(diǎn)坐標(biāo),如果都在范圍內(nèi),表示(x,y)坐標(biāo)不會(huì)是邊緣,打印空格,否則是邊緣,打印星號(hào)
最終結(jié)果如圖