资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

java制作五环代码 java 环形数组

用java写奥运五环。

设奥运5环为5个对象:A,B,C,D,E

创新互联公司网站建设由有经验的网站设计师、开发人员和项目经理组成的专业建站团队,负责网站视觉设计、用户体验优化、交互设计和前端开发等方面的工作,以确保网站外观精美、成都网站制作、成都网站设计易于使用并且具有良好的响应性。

则java程序如下:

ListInteger a=new ArrayListInteger(9);

ListInteger b=new ArrayListInteger();

ListInteger c=new ArrayListInteger();

ListInteger d=new ArrayListInteger();

ListInteger e=new ArrayListInteger();

ListInteger reslist =Arrays.asList(new Integer[] {1,2,3,4});

ListInteger res1list =Arrays.asList(new Integer[] {8,7,6,5});

b.add(reslist.get(0)).add(res1list.get(0));

c.add(reslist.get(1)).add(res1list.get(1));

d.add(reslist.get(2)).add(res1list.get(2));

e.add(reslist.get(3)).add(res1list.get(3));

java怎么绘制五环图案?

五环图片,其关键点是确定五个圆的中心点,只要确定了中心点,画圆就简单了,这个需要你计算了,可以先用笔在纸上画一画,想想思路,祝你成功

求计算机高人,要求JAVA的。。谢谢了! 绘图的题目不用了

//所有题的答案

1.

import java.util.Random;

public class Test33 {

public static void main(String[] args) {

Random rand = new Random();

int a, b, c;

int max, min;

a = rand.nextInt();

b = rand.nextInt();

c = rand.nextInt();

max = ab?(ac?a:c):(bc?b:c);

min = ab?(ac?a:c):(bc?b:c);

System.out.printf("三个整数:%d, %d, %d\n", a, b, c);

System.out.printf("最大数:%d\n", max);

System.out.printf("最小数:%d\n", min);

}

}

2.

import java.util.Scanner;

public class Test33 {

public static void main(String[] args) {

int num;

int sum = 0; //和

double avg; //平均数

int count = 0;

Scanner scan = new Scanner(System.in);

System.out.println("请输入整数(-1结束):");

while(true){

System.out.printf("No. %d:", count+1);

num = scan.nextInt();

if(num==-1){

break;

}

if(num1 || num100){

continue;

}

if(!(num%3==0 num%5!=0 num%9!=0)){

continue;

}

sum += num;

count++;

}

avg = 1.0 * sum / count;

System.out.printf("所有数的和:%d\n", sum);

System.out.printf("所有数的平均值:%.2f\n", avg);

}

}

3.

public class Test33 {

public static void main(String[] args) {

int num;

int count = 0;

int i, j;

for(i=0; i=9; i++){

for(j=0; j=9; j++){

num = 10023 + 1000 * i + 100 * j;

if(num%57==0 || num%67==0){

System.out.printf("第%2d种可能 : %d\n", ++count, num);

}

}

}

}

4.

/

5.

public class Test33 {

public static void main(String[] args) {

int num;

int count = 0;

System.out.println("100以内的所有素数:");

for(num=2; num=100; num++){

if(isPrime(num) == true){

count++;

System.out.printf("%6d", num);

}

}

System.out.println("\n素数总数:" + count);

}

public static boolean isPrime(int num){

int i, k;

if(num == 2){

return true;

}

k = (int)Math.sqrt(num);

for(i=2; i=k; i++){

if(num%i == 0){

return false;

}

}

return true;

}

}

6.

public class Test33 {

public static void main(String[] args) {

int total = 100;

int num1; //一分硬币数

int num2; //二分硬币数

int num5; //五分硬币数

int count = 0; //换法总数

for(num1=1; num1=total; num1++){

for(num2=1; num2=total/2; num2++){

for(num5=1; num5=total/5; num5++){

if(num1+2*num2+5*num5 == total){

count++;

System.out.printf("换法%-3d:一分硬币数:%2d,二分硬币数:%2d,五分硬币数:%2d\n", count, num1, num2, num5);

}

}

}

}

System.out.println("共有" + count + "种换法");

}

}

7.

import java.util.Scanner;

public class Test33 {

public static void main(String[] args) {

int n;

Scanner scan = new Scanner(System.in);

System.out.print("输入数列的大小(n):");

n = scan.nextInt();

System.out.println("Fibonacci数列");

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

System.out.print(fabonacci(i) + ", ");

}

System.out.print(fabonacci(n));

}

public static long fabonacci(int num){

if(num==1 || num==2){

return 1;

}

return fabonacci(num-1) + fabonacci(num-2);

}

}

8.

public class Test33 {

public static void main(String[] args) {

int num;

int a, b, c;

System.out.println("满足条件的所有三位自然数:");

for(num=100; num1000; num++){

a = num/100;

b = num/10%10;

c = num%10;

if(a*a*a+b*b*b+c*c*c == num){

System.out.println(num);

}

}

}

}

9.

import java.util.Scanner;

public class Test33 {

public static void main(String[] args) {

int n;

long sum;

Scanner scan = new Scanner(System.in);

System.out.print("输入正整数(n):");

n = scan.nextInt();

sum = summary(n);

System.out.printf("1!+2!+...+%d! = %d\n", n, sum);

}

public static long fact(int num){

long f = 1;

for(int i=2; i=num; i++){

f *= i;

}

return f;

}

public static long summary(int num){

long sum = 0;

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

sum += fact(i);

}

return sum;

}

}

10.

import java.util.Scanner;

public class Test33 {

public static void main(String[] args) {

double a, b, c;

double x1, x2;

double delta;

Scanner scan = new Scanner(System.in);

System.out.print("a = ");

a = scan.nextDouble();

System.out.print("b = ");

b = scan.nextDouble();

System.out.print("c = ");

c = scan.nextDouble();

delta = b*b-4*a*c;

if(a == 0){

if(b == 0){

System.out.println("一元一次方程无解!");

}

else{

System.out.printf("一元一次方程 x = %.4f\n", 1.0 * c / b);

}

}

else {

if(delta 0){

System.out.println("一元二次方程无实根!");

}

else if(delta == 0){

x1 = -1.0 * b / (2*a);

System.out.printf("一元二次方程有两个相等实根 x1 = x2 = %.4f\n", x1);

}

else{

x1 = (-1.0 * b + Math.sqrt(delta)) / (2*a);

x2 = (-1.0 * b - Math.sqrt(delta)) / (2*a);

System.out.printf("一元二次方程有两个不同的实根 x1 = %.4f, x2 = %.4f\n", x1, x2);

}

}

}

}

11.

public class Test33 {

public static void main(String[] args) {

int a, b, c;

int num;

int count = 0;

for(a=1; a=4; a++){

for(b=1; b=4; b++){

for(c=1; c=4; c++){

num = 100*a + 10*b + c;

count++;

System.out.printf("%4d", num);

if(count%10==0){

System.out.println();

}

}

}

}

System.out.println("\n共有无重复的三位数 " + count + " 个");

}

}

12.

import java.util.Scanner;

public class Test33 {

public static void main(String[] args) {

int n;

int sign = 1;

int sum = 0;

Scanner scan = new Scanner(System.in);

while(true){

System.out.print("输入奇数(n):");

n = scan.nextInt();

if(n0 n%2==1){

break;

}

}

for(int i=1; i=n; i+=2){

sum += sign * i;

sign *= -1;

}

System.out.println("1-3+5-7+...+n = " + sum);

}

}

13.

import java.util.Random;

import java.util.Scanner;

public class Test33 {

public static void main(String[] args) {

//利用随机数生成一个包含n(n50)个二位整数的数组,二位整数的数组的数值在[10,60],输出数组。

//并求出最大数和最小数,并显示出结果。

int i, n;

int[] arr;

int max, min;

Random rand = new Random();

Scanner scan = new Scanner(System.in);

while(true){

System.out.print("输入数组大小(0n50):");

n = scan.nextInt();

if(n0 n50){

break;

}

}

arr = new int[n];

for(i=1; in; i++){

arr[i] = rand.nextInt(60);

if(arr[i] 10){

arr[i] += 10;

}

}

max = min = arr[0];

for(i=1; in; i++){

if(arr[i] max){

max = arr[i];

}

else if(arr[i] min){

min = arr[i];

}

}

System.out.println("所有二位整数:");

for(i=1; i=n; i++){

System.out.printf("%3d", arr[i-1]);

if(i%10==0){

System.out.println();

}

}

System.out.printf("\n最大数:%d,最小数:%d\n", max, min);

}

}

14.

import java.util.Scanner;

public class Test33 {

public static void main(String[] args) {

int i, n;

int f1=1, f2=2;

double sum = 0;

Scanner scan = new Scanner(System.in);

while(true){

System.out.print("输入数列的前n项(n0):");

n = scan.nextInt();

if(n0){

break;

}

}

for(i=1; i=n; i++){

sum += 1.0 * f2 / f1;

f2 = f1 + f2;

f1 = f2 - f1;

}

System.out.printf("数列前%d项的和 = %.4f\n", n, sum);

}

}

15.

public class Test33 {

public static void main(String[] args) {

int total = 100; //总金额

int cock; //公鸡数

int hen; //母鸡数

int chicken; //小鸡数

int count = 0; //方案总数

for(cock=0; cock=total/5; cock++){

for(hen=0; hen=total/3; hen++){

for(chicken=0; chicken=total*3; chicken++){

if(cock*5+hen*3+chicken/3.0 == total){

System.out.printf("方案%-3d\t公鸡:%2d只,母鸡: %2d只,小鸡: %2d只\n", ++count, cock, hen, chicken);

}

}

}

}

System.out.println("共有" + count + "种购买方案");

}

}

16.

public class Test33 {

public static void main(String[] args) {

int i, num, sum;

System.out.println("1000以内所有完数:");

for(num=1; num=1000; num++){

for(sum=1,i=2; i=num/2; i++){

if(num%i == 0){

sum += i;

}

}

if(sum == num){

System.out.println(num);

}

}

}

}

17.

public class Test33 {

public static void main(String[] args) {

int total = 1000;

int a, b, c; //单价分别为50、40、30元的3种商品的数量

int count = 0; //购买方案总数

System.out.println("所有的购买方案:");

for(a=1; a=total/50; a++){

for(b=1; b=total/40; b++){

for(c=1; c=total/30; c++){

if(a+b+c==30 50*a+40*b+30*c==total){

System.out.printf("购买方案%2d:50元商品 %2d件,40元商品 %2d件,30元商品 %2d件\n", ++count, a, b, c);

}

}

}

}

System.out.printf("购买方案总数%2d\n", count);

}

}

18.

/

19.

/

20.

public class Test33 {

public static void main(String[] args) {

int num;

int count = 0;

System.out.println("所有满足条件的5位数:");

for(num=10000; num100000; num++){

if(num%10==6 num%3==0) {

System.out.printf("No.%5d:%d\n", ++count, num);

}

}

System.out.printf("这样的5位数共有:%d\n", count);

}

}

21.

public class Test33 {

public static void main(String[] args) {

int total;

for(total=1; ;total++){

if(total%2==1 total%3==2 total%5==4 total%6==5 total%7==0){

break;

}

}

System.out.println("这条阶梯最少共有" + total + "阶");

}

}

22.

public class Test33 {

public static void main(String[] args) {

int num;

int a, b, c, d; //千、百、十、个位数

int m;

for(num=1000; num10000; num++){

a = num/1000;

b = num/100%10;

c = num/10%10;

d = num%10;

m = (int)Math.sqrt(num);

if(a==b c==d a!=c m*m==num){

System.out.println(num);

}

}

}

}

java怎么绘制五环图案

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

package 临时文件;

import java.awt.*;

import javax.swing.*;

public class test{

public static void main(String[] args) {

MyFrame frame = new MyFrame();

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//1

frame.setSize(500,400); //2

frame.setVisible(true); //3

}

}

class MyFrame extends JFrame

{

public MyFrame()

{

// get screen dimensions

Toolkit kit = Toolkit.getDefaultToolkit();

Dimension screenSize=kit.getScreenSize();

int screenHeight = screenSize.height;

int screenWidth = screenSize.width;

// center frame in screen

setSize(screenHeight/2,screenWidth/2);

setLocation(screenHeight/4,screenWidth/4);

// set frame icon and title

Image img = kit.getImage("icon.gif");

setIconImage(img);

setTitle("myframe");

Container contentPane=getContentPane();

contentPane.add(new DrawRings());

}

}


新闻标题:java制作五环代码 java 环形数组
标题网址:http://cdkjz.cn/article/dojohdc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220