真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java代碼寫五星紅旗,五星紅旗編程

請問一個使用fillPolygon()畫國旗上的五角星的算法

給你一個五星紅旗的applet,用applet查看器就可以看。其它的你自己來吧

創(chuàng)新互聯(lián)公司主要從事做網(wǎng)站、網(wǎng)站制作、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)馬山,10余年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108

import java.awt.*;

import java.applet.*;

public class HongQi extends Applet{

int r1=30; //外接大圓半徑

int r0=(int)(r1*Math.cos(72*Math.PI/180)); //內(nèi)圓半徑

// 以下是大五角星坐標(biāo)

int[] xrr={

(int)0, (int)(r0*Math.cos(54*Math.PI/180)),

(int)(r1*Math.sin(72*Math.PI/180)), (int)(r0*Math.cos(18*Math.PI/180)),

(int)(r1*Math.cos(54*Math.PI/180)), (int)0,

(int)((-r1)*Math.cos(54*Math.PI/180)),(int)((-r0)*Math.cos(18*Math.PI/180)),

(int)((-r1)*Math.sin(72*Math.PI/180)),(int)((-r0)*Math.cos(54*Math.PI/180))

};

int[] yrr={

(int)-r1, (int)(-r0*Math.sin(54*Math.PI/180)),

(int)(-r1*Math.cos(72*Math.PI/180)), (int)((r0)*Math.sin(18*Math.PI/180)),

(int)((r1)*(Math.sin(54*Math.PI/180))), (int)(r0),

(int)((r1)*(Math.sin(54*Math.PI/180))), (int)((r0)*Math.sin(18*Math.PI/180)),

(int)(-r1*Math.cos(72*Math.PI/180)), (int)(-r0*Math.sin(54*Math.PI/180)),

};

int[] xrr0=new int[10]; //小五角星坐標(biāo)

int[] yrr0=new int[10];

public void init(){

for (int i = 0; i xrr.length; i++) { //計算大五角星坐標(biāo)平移

xrr[i]+=50;

yrr[i]+=60;

}

for (int i = 0; i xrr0.length; i++) { //計算小五角星坐標(biāo)平移

xrr0[i]=xrr[i]/3;

xrr0[i]+=80;

yrr0[i]=yrr[i]/3;

yrr0[i]+=17;

}

}

public void paint(Graphics g){

g.setColor(Color.RED);

g.fillRect(0,0,300,200);

g.setColor(Color.YELLOW);

g.fillPolygon(xrr,yrr,10);

g.fillPolygon(xrr0,yrr0,10);

g.copyArea(88,25,20,20,15,18);

g.copyArea(88,25,20,20,15,38);

g.copyArea(88,25,20,20,0,58);

}

}

5! 用java編寫代碼怎么寫

用于你只是求5的階乘,所以沒必要弄得那么麻煩,不用對被階乘數(shù)進(jìn)行判斷。當(dāng)然可以更加復(fù)雜一點。

public class Demo{

public static void main(String[] args){

int a = 5;

int result = 1;

for(int i = 1;i = a; i ++){

result *= a;

}

System.out.println("5!的結(jié)果是: " + result);

}

}

如何用java寫這段代碼?

import java.security.InvalidKeyException;import java.security.NoSuchAlgorithmException;import javax.crypto.BadPaddingException;import javax.crypto.Cipher;import javax.crypto.IllegalBlockSizeException;import javax.crypto.KeyGenerator;import javax.crypto.NoSuchPaddingException;import javax.crypto.SecretKey;public class JEncrytion{

public static void main(String[] argv) {

try{ KeyGenerator keygenerator = KeyGenerator.getInstance("DES"); SecretKey myDesKey = keygenerator.generateKey();

Cipher desCipher; // Create the cipher

desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");

// Initialize the cipher for encryption

desCipher.init(Cipher.ENCRYPT_MODE, myDesKey); //sensitive information

byte[] text = "No body can see me".getBytes();

System.out.println("Text [Byte Format] : " + text);

System.out.println("Text : " + new String(text));

// Encrypt the text

byte[] textEncrypted = desCipher.doFinal(text);

System.out.println("Text Encryted : " + textEncrypted);

// Initialize the same cipher for decryption

desCipher.init(Cipher.DECRYPT_MODE, myDesKey); // Decrypt the text

byte[] textDecrypted = desCipher.doFinal(textEncrypted);

System.out.println("Text Decryted : " + new String(textDecrypted));

}catch(NoSuchAlgorithmException e){

e.printStackTrace();

}catch(NoSuchPaddingException e){

e.printStackTrace();

}catch(InvalidKeyException e){

e.printStackTrace();

}catch(IllegalBlockSizeException e){

e.printStackTrace();

}catch(BadPaddingException e){

e.printStackTrace();

}

}

}

Java編程,填寫下面的代碼

class NoLowerLetterException extends Exception {

public NoLowerLetterException(String msg) {

super(msg);

}

}

class NoDigitException extends Exception {

public NoDigitException(String msg) {

super(msg);

}

}

class People {

void printLetter(char c) {

if (c = 'a' c = 'z') {

System.out.println(c);

} else {

try {

throw new NoLowerLetterException(String.valueOf(c));

} catch (NoLowerLetterException e) {

e.printStackTrace();

}

}

}

void printDigit(char c) {

if (c = '0' c = '9') {

System.out.println(c);

} else {

try {

throw new NoDigitException(String.valueOf(c));

} catch (NoDigitException e) {

e.printStackTrace();

}

}

}

}

public class ExceptionExample {

public static void main(String args[]) {

People people = new People();

for (int i = 0; i 128; i++) {

// 【代碼5】

// //將i轉(zhuǎn)換為char類型,執(zhí)行people.printLetter()方法,如果出現(xiàn)異常則捕獲,并輸出異常的錯誤信息!

people.printLetter((char) i);

}

for (int i = 0; i 128; i++) {

// 【代碼6】 //將i轉(zhuǎn)換為char類型,執(zhí)行people. printDigit

// ()方法,如果出現(xiàn)異常則捕獲,并輸出異常的錯誤信息!

people.printDigit((char) i);

}

}

}

怎樣用java編國旗

/**

* @(#)ChinaFlag.java

* ChinaFlag Applet application

* @黑色珊瑚

* @version 1.00 08/05/12

*/

import java.awt.*;

public class ChinaFlag extends Frame {

public static void main(String[] args) {

ChinaFlag cf=new ChinaFlag();

cf.setVisible(true);

}

public ChinaFlag() {

setBounds(100,100,400,300);

setBackground(Color.RED);

}

public void paint(Graphics g) {

drawStar(g,70,100,40);

drawStar(g,140,60,12);

drawStar(g,155,86,12);

drawStar(g,155,113,12);

drawStar(g,140,140,12);

}

private void drawStar(Graphics g,int x,int y,int width) {

double[] xb={0,

0.2245139882897926f, // sin18 * tan36

1.0514622242382672f, // 1 / cos18

0.3632712640026804f, // (sin18 * cos36) * sin72

0.5877852522924731f,0, // sin36 , 0

-0.5877852522924731f, // -sin36

-0.3632712640026804f, // -(sin18 * cos36) * sin72

-1.0514622242382672f, // -1 / cos18

-0.2245139882897926f}; // -sin18 * tan36

double[] yb={-1,

-0.3090169943749474f,

-0.3090169943749474f,

0.1180339887498948f, //

0.8090169943749474f,

0.3819660112501051f,

0.8090169943749474f,

0.1180339887498948f, //

-0.3090169943749474f,

-0.3090169943749474f};

g.setColor(Color.YELLOW);

int[] x1=new int[10];

int[] y1=new int[10];

for (int i=0; i10; i++) {

x1[i]=(int)(xb[i]*width+x);

y1[i]=(int)(yb[i]*width+y);

}

g.fillPolygon(x1,y1,10);

}

}

用java寫程序,求教

求采納,代碼:

import java.util.Scanner;

public class main {

public static void main(String[] arg) {?

//

int NumF=0;

//負(fù)數(shù)個數(shù)?

int NumZ=0;

//正數(shù)個數(shù)

double sum=0;

//數(shù)字總和?

System.out.println("輸入數(shù)字:");?

Scanner in=new Scanner(System.in);?

String st=in.nextLine();//獲得輸入的內(nèi)容

//循環(huán)遍歷數(shù)組?

for(String a:st.split(" ")/*使用split分割字符串*/) {?

int b = 0;?

try {

b=Integer.valueOf(a);//使用Integer.valueOf();將字符串轉(zhuǎn)化為數(shù)值

}catch (Exception e) {?

System.out.println("發(fā)生錯誤,可能輸入了錯誤的數(shù)");?

e.printStackTrace();?

}?

//判斷數(shù)字正負(fù)?

if(b0) {

//如果是負(fù)數(shù)

NumF++;

//

sum=sum+b;

}else if (b0){

//如果是正數(shù)

NumZ++;?

sum=sum+b;?

}else if(b==0) {?

//如果為0就結(jié)束程序

System.out.println(NumZ);?

System.out.println(NumF);

System.out.println((double)sum/(NumF+NumZ));

}?

}?

}

}


文章題目:java代碼寫五星紅旗,五星紅旗編程
文章URL:http://weahome.cn/article/hcjpoi.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部