* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Seminar 01 - Probleme simple
Survey
Document related concepts
Mathematics of radio engineering wikipedia , lookup
Infinitesimal wikipedia , lookup
Positional notation wikipedia , lookup
Location arithmetic wikipedia , lookup
Georg Cantor's first set theory article wikipedia , lookup
Collatz conjecture wikipedia , lookup
Hyperreal number wikipedia , lookup
Large numbers wikipedia , lookup
Real number wikipedia , lookup
P-adic number wikipedia , lookup
Transcript
Laboratory 01 Object Oriented Programming Simple programs in C/C++ Objective Theoretical aspects Specification, design and implementation of simple problems in C/C++. General aspects of C/C++ language. Structured vs. modular versions of a C/C++ application. Assignment Write two programs in C/C++ in order to solve one of the following problems: - the first program must be a structured application – all the source code has to be in a single file - the second program must be a modular application: you must have minimum 3 files: o a header file (extension “modul.h”) for declaring the data types and the functions required to solve the problem o a source file (extension “modul.c”/”modul.cpp”) for implementing the functions declared in “modul.h” o a source file (extension “mainApp.c”/”mainApp.cpp”) for the main algorithm Consult the example from Example folder. For documentation, follow the model learnt at Fundamentals of Programming: - problem statement - usage scenario - feature list - iterations 1. Generate all the prime numbers smaller than a given natural number n. 2. Generate the first n prime numbers (n is a given natural number). 3. Determine the age of a person, in number of years. The person birthday and the current date are given as calendar data (as year, month and day). 4. Determine all the possible representations of a number as sum of consecutive natural numbers. 5. Determine the first n digits of the sub unitary fraction k/m = 0.c1c2c3..., where k and m are two natural numbers. 6. Print the first k terms of the sequence 1, 2, 1, 3, 2, 1, 4, 2, 2, 5, 4, 3, 2, 1, 6, 2, 2, 3, 3, 3, 7, 6, ... obtained form the sequence of natural numbers by replacing each number n by group of numbers: a prim number p is replaced by the numbers p, p-1, …, 3, 2, 1, and a composed number n is replaced by n, followed by all its proper divisors, each divisor d being repeated d times. 7. Print Pascal triangle of dimension n of all combinations C(m,k) of m objects taken by k, k = 0, 1, ..., m, for line m, where m = 1, 2, ..., n. Laboratory 01 Object Oriented Programming 8. Compute the approximated value of square root of a positive real number. Use a given precision. 9. Print the exponent of a prime number p from the decomposition in prime factors of a given number N = 1*2*...*n (n is a non-null natural number). 10. Read a sequence of natural numbers (ended by 0) and determine the number of 0 digits of the product of the read numbers. 11. Print a given number of partial sums from the series: sin(x) = x - x^3/3! + x^5/5! x^7/7! + ... 12. Read sequences of positive integer numbers (reading of each sequence ends by 0, reading of all the sequences ends by -1) and determine the maxim element of each sequence and the maxim element of the global sequence. 13. Determine the intersection of two segments (from the same plan and given by their Cartesian coordinates). 14. Determine a calendar data (as year, month, day) starting from two integer numbers representing the year and the day number inside that year. 15. Determine the value x^n, where x is a real number and n is a natural number, by using multiplication and squared operations. 16. Decompose a given natural number in its prime factors. 17. Decompose a given odd natural number, grater than 2, as a sum of two prime numbers (check the hypothesis of Goldbach). 18. Determine the first n pairs of twin numbers, where n is a given natural and non-null number. Two prime numbers p and q are called twin if q – p = 2. 19. Determine all the numbers smaller than a given natural and non-null number n and that are relative prime to n. 20. Determine the first 10 natural numbers (x1, x2, …, x10) greater than 2 with the following property: all the natural numbers smaller than xi and that are prime with xi are prime, i =1,2, …, n. Deadline Documentation – Laboratory 2 Implementation – Laboratory 2