Presentation is loading. Please wait.

Presentation is loading. Please wait.

Algorithms. Algorithm (1) Read 8-digit integers from a file to an array Verify which of these numbers are real dates, which are not Don’t forget leap.

Similar presentations


Presentation on theme: "Algorithms. Algorithm (1) Read 8-digit integers from a file to an array Verify which of these numbers are real dates, which are not Don’t forget leap."— Presentation transcript:

1 Algorithms

2 Algorithm (1) Read 8-digit integers from a file to an array Verify which of these numbers are real dates, which are not Don’t forget leap year! E.g. 27041998, 29022003, 58042013, 04132013 etc 20152

3 Algorithm (2) Client wishes to withdraw cash from an ATM The ATM gives the client the specified amount of cash, moreover, it will give the least amount of bills possible Currency will be Euro banknotes. Verify, that it’s possible to withdraw the sum specified by the client. E.g.537€ - Error (no 2-euro banknote) 195€ -1x100€ + 1x50€ + 2x20€ + 1x5€ 20153

4 Algorithm (3) Cargo is being brought to an intermediary storage from 2 storage complexes before shipping out from there. For storage complexes, use 2 arrays A and B as integer arrays for the weight of the cargo units. Cargo must exit the intermediary storage heavier units first. E.g. Storage A: 7, 59, 1, 93, 15, 27, 48, 6 Storage B: 9, 3, 1, 94 Exit order from intermediary: 94, 93, 59, 48, 27, 15, 9, 7, 6, 3, 1, 1 20154

5 Algorithm (4) User inputs 4-character words as strings Check, which of those numbers are definitely hexadecimal, which binary and which don’t belong to either. Assume, that hexadecimal numbers include at least one digit higher than ‘1’ E.g. 0110, AZY1, 001F, 0101, 0Y24 etc 20155

6 Algorithm (5) Text is read from a file Find the frequency of characters in the text Lower- and uppercase characters are treated as the same Words are separated by dashes Word separators and punctuation symbols (comma, dot, hyphen, colon, semicolon, braces, quotes etc) are ignored 20156

7 Algorithm (6) Create a n * m matrix (n > 5, m > 5) Find: The sum of the negative elements in the last row The sum of positive elements in a column. Only show the sums from the columns to the right of the third column. Show sum for each column separately. The product of negative elements in a row. Do this for rows higher than the fourth row. Show product for each row separately. Display all the results found. 20157

8 Algorithm (7) You’re given an array of integers with a length of N Place the elements so that negative numbers come first and positive numbers follow them Don’t change the order of appearance E.g. Original: 5, -7, -87, -221, 7, 97, 1, -5, 5 Result: -7, -87, -221, -5, 5, 7, 97, 1, 5 20158

9 Algorithm (8) Read product weights and codes from a file Find extremums and ratios between weights and extremums Output ratios with product codes E.g.Weights: 6, 7, 2, 10, 4 Prod. codes: 790A1, 001A1, 117CA, 000A2, 01010 Product 790A1 ratios are 3.0 and 0.6 Product 001A1 ratios are 3.5 and 0.7 Product 117CA ratios are 1.0 and 0.2 etc 20159

10 Algorithm (9) User inputs decimal numbers (integers) from the keyboard until ‘0’ is typed User inputs a new base (radix) Sisse loetud arvud teisendatakse soovitud arvusüsteemi ja väljastatakse kõrvuti nende kümnendsüsteemi väärtustega 201510

11 Algorithm (10) N 4-byte binary numbers are read from a file Numbers will be converted into decimal and hexadecimal Results will be stored in a file alongside their originals in binary 201511


Download ppt "Algorithms. Algorithm (1) Read 8-digit integers from a file to an array Verify which of these numbers are real dates, which are not Don’t forget leap."

Similar presentations


Ads by Google