Студопедия
Случайная страница | ТОМ-1 | ТОМ-2 | ТОМ-3
АрхитектураБиологияГеографияДругоеИностранные языки
ИнформатикаИсторияКультураЛитератураМатематика
МедицинаМеханикаОбразованиеОхрана трудаПедагогика
ПолитикаПравоПрограммированиеПсихологияРелигия
СоциологияСпортСтроительствоФизикаФилософия
ФинансыХимияЭкологияЭкономикаЭлектроника

Task 1. One-dimensional arrays

Читайте также:
  1. Creation and using one-dimensional and multi-dimensional arrays in the programming language Java.
  2. Jagged Arrays
  3. Parameter arrays
  4. Single-Dimensional Arrays

1) Write a program that fills in an array of 8 elements with numbers in the decreasing order.

2) Write a program that a program that fills in an array of 8 elements with numbers in the ascending order.

3) Write a program that a asks user to type in elements of an array and deletes all numbers that are equal to 0 from the array.

4) Write a program which will ask a user to enter numbers for A array and which will output all negative numbers and numbers that are less than 50.

5) Write a program which will ask a user to enter numbers for B array and which will output all even numbers and numbers ending with 0.

6) Write a program that asks a user to type 10 integers and writes how many times the biggest value occurred.

7) Write a program that asks a user to type n integers and prints out a number of negative numbers and all of the negative numbers in the next line.

8) Write a program that shows the output array of 10 numbers. It must ask which numbers you want to delete and then print out a new array.

9) Write a program that asks a user to type n integers and prints out a number of positive numbers and all of the positive numbers in the same line in brackets.

10) Write a program that asks a user to enter two arrays A and B and outputs A∩B.

11) Write a program that asks a user to enter two arrays A and B and outputs AUB.

12) Write a program that searches an array of ten integers for duplicate values. Make the program display each duplicate found.

13) Aerosvit Airlines provides flights from Kyiv to six other cities in Ukraine. The cities are referred to by number, 1 to 6. The price of a round-trip ticket to each city is shown here.

City            
Price 56.79 105.69 93.49 155.99 87.49 73.99

Write a program that computes the total price of tickets ordered by a customer. The program should prompt the user for the number of the destination city and the number of tickets desired. If the user enters an invalid city number, the program should display an error message and terminate. The program should display the total price of the ticket order. Use an array to store the ticket price table.

14) Write a program that prompts the user to enter a ten-element array and displays the array. Then, the program must use the bubble sort to sort the array in the increasing order and display the sorted array.

15) Write a program that finds roots of the equation Ax + Bsina = 0, where a = 1.3, A = {1.1, 2.5, 3.9, 8.1, 4.5, 12.1, 11.9, 15.5}.

(i = 1..8).

16) Write a program that calculates the following array: , where is positive root of the equation Ax + Bcosb = 0, with А = 0.75, B = 4.5, b = -1.5.. 2.5, .

17) Write a program that sums of all positive elements of an array A = {-1.2, 3.5, 4.1, 8.5, 5.3, -6.1, 3.4, 2.7}.

18) Write a program that finds product of elements of an array A = {1, 3.5, 4, -0.8, 1.9, 5, 13} which satisfies the following condition , if С = 2, D = 10.

19). Write a program that calculates

with Y = -5.5, X = {-1.8, -1.6,..., 1.2}. The result should be presented in the form of an array.

20) Write a program that finds numbers of the first odd and the last even numbers of an array N = {10, 8, 4, 3, 6, 15, 2}.

21) Write a program that prompts a user to enter a ten-element array and displays the array. Then, the program must use the bubble sort to sort the array in the decreasing order and display the sorted array.

22) Write a program that finds the difference between the maximum and K-th element of an array А = {-1.1, 2.5, -2.9, 8.8, 14.5, 2.2, -1.3, 5.9} if К = 4.

23) Write a program that calculates the element of an array

where x – the roots of a series of equations Аx + sin(i) = 0, ,

А = 5.5.

24) Write a program that sums of the first К positive elements of an array А = (2.8, -3.5, -2.1, 4, 6, 8.1, 6.2, 9.5, 1.1). К = 5.

25) Write a program that finds a product of the last N negative elements of an array А = (-5, 6.1, -9.2, 4, 5, -2, 7, -1, 5, 4, 1.9, -3, 5); N = 3.

26) Create an array , even elements of the array are equal to the elements of an array А = (-5.1, 2.3, 4.6, 5.8, -2.9), odd ones to the elements of an array В = (2.8, 3, 5.4, -1.9, -4.1).

27) Find the amount of positive, negative elements and elements equal to 0 of an array М = (-5, 0.1, 2.8, 0.64, 3, -5.1, 0, -7.5, 4.6, 10).

28) Calculate where х = , an array, its elements are the remainders of the division of the entire array N = (156, 18, 72, 10, 95, 100) into an integer number К = 9.

29) Calculate , where and are maximum and minimum elements of an array А = (5.5, -6, 8, 9.1, -3.5, 4.1, 10, -1, 2.5) respectively; – arithmetic mean of and .

30) A survey organization telephones 20 homes and records the household income of each family surveyed. Write a program that inputs the 20 incomes into an array and then sorts the array in the decreasing order. The program should display the following statistics: the maximum income, the minimum income, the average income, and the median income. The median of a set of sorted numbers is the middle number, if there is an odd number of numbers. If there is an even number of numbers, the median is the average of the two middle numbers.

 


Дата добавления: 2015-11-14; просмотров: 58 | Нарушение авторских прав


<== предыдущая страница | следующая страница ==>
Jagged Arrays| Task 2. Multidimensional array

mybiblioteka.su - 2015-2024 год. (0.006 сек.)