Вы находитесь на странице: 1из 3

Problem 1:

If n is an integer greater than 0, n factorial (n!) is the product: n* (n-1) * (n-2) * ( n-3) *
By convention, 0! = 1.
You must write a program that allows a user to enter an integer between 1 and 7. Your program must then
compute the factorial of the number entered by the user.
Your solution MUST actually perform a computation (i.e., you may not simply print 5040 to the screen
as a literal value if the input is 7).

************************************************************
************************************************************
************************************************************

Problem 2:
Write a program to find the shortest routing and distance between two Alabama cities using the following
distance table.
You are not allowed to use any other manually computed distances in your program.
Alabaster-Birmingham 24 miles
Alabaster-Montgomery 71 miles
Birmingham-Huntsville 103 miles
Birmingham-Tuscaloosa 59 miles
Demopolis-Mobile 141 miles
Demopolis-Montgomery 101 miles
Demopolis-Tuscaloosa 65 miles
Mobile-Montgomery 169 miles
Montgomery-Tuscaloosa 134 miles
Example 1:
Enter city #1: Demopolis
Enter city #2: Birmingham
Shortest routing and distance:
Demopolis-Tuscaloosa-Birmingham, 124 miles

************************************************************
************************************************************
************************************************************

Problem 3:
General Statement: The Jones Trucking Company tracks the location of each of its trucks on a grid
similar to an (x, y) plane. The home office is at location (0, 0). Read the coordinates of truck A and the
coordinates of truck B and determine which is closer to the office.
Input: The first line of the data set for this problem is an integer representing the number of collections of
data that follow. Each collection contains 4 integers: the x-coordinate and then the y-coordinate of truck
A followed by the x-coordinate and then the y-coordinate of truck B.

************************************************************

************************************************************
************************************************************

Problem 4:
In this problem you must write a program that determines if two circles intersect each other. The input to
your program will be the coordinates for the center of each circle, followed by the radius of each circle.
The output will state whether the circles overlap, do not overlap, or are tangential (i.e., tangential circles
touch each other at just one common point).
Example 1:
Enter the coordinates and radius for circle 1: 10 10 3
Enter the coordinates and radius for circle 2: 10 6 1
The circles are tangential.

************************************************************
************************************************************
************************************************************

Problem 5:
The sum of the squares of the first ten natural numbers is,
12 + 22 + ... + 102 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)2 = 552 = 3025
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the
sum is 3025 385 = 2640.
Find the difference between the sum of the squares of the first one hundred natural numbers and the
square of the sum.

************************************************************
************************************************************
************************************************************

Problem 6:
Find the greatest product of five consecutive digits in the 50-digit number.
73167176531330624919225119674426574742355349194934

************************************************************
************************************************************
************************************************************

Problem 7:

Bubble sort is one of the classic sorting algorithm which is used to explain sorting during various
computer and engineering courses
In Bubble sort algorithm we sort an unsorted array by starting from first element and comparing with
adjacent element. If former is greater than later then we swap. And by doing this we get the largest
number at the end after first iteration. So in order to sort n elements you require n-1 iteration and
almost n-1 comparison.

Вам также может понравиться