0% found this document useful (0 votes)
26 views4 pages

Lab 1 - CEN 110

The first document is about a program that reads an integer and outputs the number of digits in that integer. The second document is about a program that reads a series of numbers, calculates the average, and outputs the number of numbers greater than the average. The third document is about a program that reads rows of numbers, finds the maximum number in each row, calculates the processing cost of each row based on the differences from the maximum, and outputs the row with the minimum cost.

Uploaded by

lina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views4 pages

Lab 1 - CEN 110

The first document is about a program that reads an integer and outputs the number of digits in that integer. The second document is about a program that reads a series of numbers, calculates the average, and outputs the number of numbers greater than the average. The third document is about a program that reads rows of numbers, finds the maximum number in each row, calculates the processing cost of each row based on the differences from the maximum, and outputs the row with the minimum cost.

Uploaded by

lina
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Number of digits

Shqip
Read an integer number and then show the number of digits that the number has.
Input specification
There will be only one integer number in the input which is between 1 and 3 billion.
Output specification
Show the numbers of digits that the given number has.

Input Output

3344 4

http://acm.epoka.edu.al:8888/en/problem-pid-c596 (use 1 function)

Number of Numbers over Average

You are given a series of numbers, show the number of numbers which are greater than the average.

Input specification
The first number is the number of numbers (n) in the series where 1 < n ≤ 100.000. Then you will be given n
integer numbers where each of the is between -10.000 and 10.000.

Output specification
Just give one number which shows the number of numbers which are greater than the average of the series.

Sample Input I:
5
12345

Sample Output I:
2

Sample Input II:


5
-898 -833 570 245 629

Sample Output II:


3

http://acm.epoka.edu.al:8888/en/problem-pid-c49b

Processing Cost
Assume that processing a list of items costs the sum of
differences between the item and the max value in that
series. For example if we are given the series: 5 3 2 7,
thus, the max of this series is 7. Then, the processing
cost of it is

= (7-5) + (7-3) + (7-2) + (7-7)


= 2 + 4 + 5 + 0 = 11.

Question: Write a program that is going to read n


rows of m element series and then the program will
find the minimum processing cost.

Input specification
In the first line, you will be given two numbers (n and
m). Then, in the following n lines, you will be given m
integers which are between -20000 and 20000 where n
and m are between 1 and 20000

Output specification
Show one integer: Minimum processing cost.

Sample Input I Sample Input II


3 4 2 4
7 1 7 9 5 3 2 7
4 10 8 8 5 13 2 17
9 2 6 3

Sample Output I Sample Output II


10 11

Explanation:
In sample input 1, there are 3 rows with 4 elements. The max of first row is 9 and the processing cost of it 12.
The max of the second row is 10 with a total processing cost of 10 (6+0+2+2). Then the third series has the
max of 9. And it’s processing cost is 16. So, the second row has the minimum processing cost: 10.

http://acm.epoka.edu.al:8888/en/problem-pid-c513

Random Sorted List

For his experiments, your professor wants to use sorted lists with n elements. The list will be produced
randomly, but at the same time he needs the list to be sorted in ascending order.

Question: Write a program that that produces random but sorted list where

• the list has n elements and


• the difference between any two consecutive list elements is smaller than k (between 0 and k-1)

Note: Nearly all programming languages have a randum number function. For C/C++, you can use rand()
function (from stdlib.h library) to produce a random number. For Example, in the statement:
r = rand()%10;
r will have a random value between 0 and 9.

Input specification
You will be given 2 integers: n, k; where n is between 1 and 5000 and 1 ≤ k ≤ 50.
Output specification
(Assume that the previous number before the first number is 0) Show the sorted list separated by spaces

Sample Input I Sample Input II


10 5 15 4
Sample Output I Sample Output II
3 5 7 11 11 11 13 16 17 17 2 4 7 10 12 14 17 18 20 20 23 23 23 24 25

http://acm.epoka.edu.al:8888/en/problem-pid-c490

Random Password Generator

The university gives passwords to users. This is done through


an automatized system. Every student is given an 8
characters long random password. The passwords have the
following format:

• The first 3 chars are random uppercase English


letters
• Following 3 chars are random lowercase English
letters
• The last 2 chars are random digits (from 0..9)

Question:
Write a program that produces n random passwords.

Input specification
You will be given just one integer (n) where n is between 1 and 1000.

Output specification
Show n passwords with the given format above in n lines. All passwords must be different than all others.

Sample Input I Sample Output I


5 BMVwzf34
KWDsku81
FDGqtm70
ZUNygc36
HTKhqe53

http://acm.epoka.edu.al:8888/en/problem-pid-c4e9

Missing Number
Shqip

Mr John is a maths professor. He writes the exercises the students have to solve on the blackboard.

He writes a sequence of N different positive integers(0 < N < 1000) on the board but the students are lazy and
don’t want to study, so, they usually erase one number for fun.

As this happens so often he wants you to write a program to help him with it.

Input specification
-In the first line you will get N(the number of positive integers).
-After that in the next line you will get N positive integers
-In the third line you will read N-1 positive integers. There is no number greater than 1000.

Output specification
The number that got erased.

Sample Input I Sample Input II


4 13
4 6 3 7 9 8 9 7 4 2 6 1 8 4 6 2 5
7 3 4 9 8 9 7 4 2 6 1 8 4 6 5
Sample Output I Sample Output II
6 2

http://acm.epoka.edu.al:8888/en/problem-pid-c491

You might also like