0% found this document useful (0 votes)
26 views

CS310 Assignment 1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

CS310 Assignment 1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment 1

Ex1 (easy): Given a positive integer n, find all integer having 4 digits which is
divisible by n.

• Input: a positive integer n (1 ≤ n ≤ 9999)


• Output: Write the sequence of numbers found (elements are separated by
a SPACE character)

Example

Input Output
2000 2000 4000 6000 8000

Ex2 (easy): Given an integer n, write a program that generates all the binary
sequences of length n in a lexicographic order.

• Input: an integer n (1 ≤ n ≤ 20)


• Output: Write binary sequences in a lexicographic order, each sequence in
a line

Example

Input Output
3 000
001
010
011
100
101
110
111

Ex3 (medium): Given a document T and two strings P1, P2 (both having no enter
character and no more 1000 character). Let replace all strings P1 in T by the string
P2.

• Input: includs 3 lines:


o Line 1: string P1
o Line 2: string P2
o Line 3: document T
• Output: Document T after the replacement
Example

Input Output
AI Recently, Artificial Intelligence is a key
Artificial Intelligence technology. Artificial Intelligence enable
Recently, AI is a key technology. AI enable efficient operations in many fields.
efficient operations in many fields.

Ex4 (medium): Data about sales in an e-commerce company (the e-commerce


company has several shops) consists a sequence of lines, each line (represents
an order) has the following information:

<CustomerID> <ProductID> <Price> <ShopID> <TimePoint>

in which the customer <CustomerID> buys a product <ProductID> with price


<Price> at the shop <ShopID> at the time-point <TimePoint>

• <CustomerID>: string of length from 3 to 10


• <ProductID>: string of length from 3 to 10
• <Price>: a positive integer from 1 to 1000
• <ShopID>: string of length from 3 to 10
• <TimePoint>: string representing time-point with the format HH:MM:SS
(for example, 09:45:20 means the time-point 9 hour 45 minutes 20
seconds)

Perform following tasks:

1. Sort orders in decreasing order of <TimePoint>


2. Provide the best-seller Product ID which is sold most and its sold quatity as
well as shop sold this product most. In case of same quantity, which shop
has higher total price is selected.
3. Provide the loyal customer who purchased most,

Example:

Input Output - Task 1

C001 P001 10 SHOP001 10:30:10 C001 P002 30 SHOP001 12:30:10


C001 P002 30 SHOP001 12:30:10 C002 P001 160 SHOP003 11:30:20
C003 P001 40 SHOP002 10:15:20 C001 P001 10 SHOP001 10:30:10
C001 P001 80 SHOP002 08:40:10 C002 P001 130 SHOP001 10:30:10
C002 P001 130 SHOP001 10:30:10 C003 P001 40 SHOP002 10:15:20
C002 P001 160 SHOP003 11:30:20 C001 P001 80 SHOP002 08:40:10

Input Output - Task 2

C001 P001 10 SHOP001 10:30:10 P001


C001 P002 30 SHOP001 12:30:10 5
C003 P001 40 SHOP002 10:15:20 SHOP001
C001 P001 80 SHOP002 08:40:10
C002 P001 130 SHOP001 10:30:10
C002 P001 160 SHOP003 11:30:20

Input Output - Task 3

C001 P001 10 SHOP001 10:30:10 C002


C001 P002 30 SHOP001 12:30:10
C003 P001 40 SHOP002 10:15:20
C001 P001 80 SHOP002 08:40:10
C002 P001 130 SHOP001 10:30:10
C002 P001 160 SHOP003 11:30:20

You might also like