Make a program, enter 10 integers, put in the array, output all the numbers in descending order, and then count and output the number of positive, negative, and zero.

Source: Internet
Author: User
public class Demo1 {public static void main (string[] args) {list<integer> list = new arraylist<integer> (); list . Add ( -1); List.add ( -2); List.add ( -4); List.add (0); List.add (2); List.add (5); List.add (9); List.add (7); List.add (-9); List.add ( -7); int num1 = 0;//Indicates the number of positive numbers int num2 = 0;//Indicates the number of negative numbers int num3 = 0;//represents the number of 0 for (int i=0;i<list.size (); i++) {if (list). Get (i) >0) {num1++;} else if (List.get (i) <0) {num2++;} else{num3++;}} System.out.println ("Number of positive numbers:" +num1+ "number of negative numbers:" +num2+ "is the number of 0:" +num3);}}

Make a program, enter 10 integers, put in the array, output all the numbers in descending order, and then count and output the number of positive, negative, and zero.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.