0% found this document useful (0 votes)
3 views2 pages

TD 03

Uploaded by

Bou Thaina
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)
3 views2 pages

TD 03

Uploaded by

Bou Thaina
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/ 2

University of 20 August 1955 - Skikda ‫ – ﺳﻜ�ﻜﺪة‬1955 ‫ أوت‬20 ‫ﺟﺎﻣﻌﺔ‬

Faculty of technology – Department of technology ‫كﻠ�ﺔ اﻟﺘﻜﻨﻮﻟﻮﺟ�ﺎ – ﻗﺴﻢ اﻟﺘﻜﻨﻮﻟﻮﺟ�ﺎ‬


1st year common core technology engineer ‫ﻣﺸ�ك ﻣﻬﻨﺪس ﺗﻜﻨﻮﻟﻮﺟ�ﺎ‬‫اﻟﺴﻨﺔ اﻷو� ﺟﺬع ت‬

TD 03
Academic year: 2024/2025 – First Semester ‫اﻟﺴﺪا� اﻷول‬
‫ي‬ - 2025/2024 : ‫اﻟﺴﻨﺔ اﻟﺪراﺳ�ﺔ‬
Module: Computer science �‫اﻵ‬
‫ﻣﻘ�ﺎس اﻹﻋﻼم ي‬

Exercise 01: :‫اﻟﺘﻤ��ﻦ اﻷول‬


We assume that we have a computer who can ‫ﻧﻔ�ض أﻧﻨﺎ ﻧﻤﺘﻠﻚ ﺟﻬﺎز ﺣﺎﺳﻮب �ﺴﺘﻄﻴﻊ ﺗﻨﻔ�ﺬ اﻟﻌﻤﻠ�ﺎت‬ ‫ت‬
perform only the following operations: :‫اﻟﺘﺎﻟ�ﺔ ﻓﻘﻂ‬
 Moving in a straight line for a distance X M OVE X ‫ف‬
X ‫ ﺗﺤﺮك ي� ﺧﻂ ﻣﺴﺘﻘ�ﻢ ﻣﺴﺎﻓﺔ‬
 Rotating at an x angle ROTATE X X ‫ اﺳﺘﺪر ﺑﺰاو�ﺔ‬
 Put down the pen PUT (‫ اﻧﺰل اﻟﻘﻠﻢ )ﻟﻠﺮﺳﻢ‬
 Lift the pen LIFT (‫ ارﻓﻊ اﻟﻘﻠﻢ )ﻟﻠﺘﻮﻗﻒ ﻋﻦ اﻟﺮﺳﻢ‬

Propose algorithms that uses these instructions ‫اﻗ�ح ﺧﻮارزﻣ�ﺎت �ﺴﺘﺨﺪم ﻫﺬە اﻟﺘﻌﻠ�ﻤﺎت ﻟﺮﺳﻢ اﻷﺷكﺎل‬ ‫ت‬
to draw the following forms: :‫اﻟﺘﺎﻟ�ﺔ‬
• A square of side length of 5 5 ‫• ﻣ��ــﻊ ﻃﻮل ﺿﻠﻌﻪ‬
• An equilateral triangle with side length of 7 7 ‫• ﻣﺜﻠﺚ ﻣتﺴﺎوي اﻷﺿﻼع ﻃﻮل ﺿﻠﻌﻪ‬
Exercise 02: ‫اﻟﺘﻤ��ﻦ ن‬
:‫اﻟﺜﺎي‬
‫ي‬
Propose an algorithm that compute the ‫ت‬
‫اﻗ�ح ﺧﻮارزﻣ�ﺔ �ﺴﻤﺢ بﺤﺴﺎب ﻣﺴﺎﺣﺔ‬
R
surface area (4πR2) and the volume ‫( ﻛﺮة ﻧﺼﻒ‬4/3 πR3) ‫( وﺣﺠﻢ‬4πR2)
(4/3πR3) of a sphere with radius R. .R ‫ﻗﻄﺮﻫﺎ‬

Exercise 03: :‫اﻟﺘﻤ��ﻦ اﻟﺜﺎﻟﺚ‬


‫ت‬
:‫اﻗ�ح ﺧﻮارزﻣ�ﺎت ﻟﻤﻌﺎﻟﺠﺔ اﻟﻤﺴﺎﺋﻞ اﻟﺘﺎﻟ�ﺔ‬
Propose algorithms that resolve these problems:
• Swapping the values of two variables ‫ﻣﺘﻐ��ﻦ‬ ‫ﺗبﺪ�ﻞ ﻗ�ﻤﺔ‬ •
‫ي‬
• Calculating the sum of natural numbers lower
N ‫ﺣﺴﺎب ﻣﺠﻤ�ع اﻷﻋﺪاد اﻟﻄﺒ�ﻌ�ﺔ اﻷﻗﻞ ﻣﻦ‬ •
than N
(�‫ﻋﺎﻣ‬
‫ي‬ N) N! ‫ﺣﺴﺎب‬ •
• Calculating N! (N factorial) ‫ت‬
��‫اﻷ‬
‫ب‬ ‫ﺣﺴﺎب اﻟﻘﺎﺳﻢ اﻟﻤﺸ�ك‬ •
• Calculating the Greatest Common Divisor GCD
‫ أو� أم ﻻ ؟‬N ‫ﻣﻌﺮﻓﺔ ﻫﻞ اﻟﻌﺪد‬ •
• Checking the primality of a number N
‫ئ‬
‫ﺧﺎ�ء‬ ‫ ﻫﻞ ﻫﻮ ﺻﺤﻴﺢ أم‬d/m/y ‫ﻣﻌن‬ ‫ﻣﻌﺮﻓﺔ ﺗﺎر�ـ ــﺦ ي ف‬ •
• Checking the validity of a specified date d/m/y
Exercise 04: :‫اﻟﺘﻤ��ﻦ اﻟﺮاﺑﻊ‬
The Collatz conjuncture presume that the following ‫ﺗﻨﺺ ﺣﺪﺳ�ﺔ ﻛﻮﻻﺗﺰ ﻋ� أن اﻟﻤﺘﺘﺎﻟ�ﺔ اﻟﺘﺎﻟ�ﺔ ﺗﺘﻘﺎرب داﺋﻤﺎ‬
suit always converge to the value 1 (or to the .(1 ،2 ،4 ‫ )أو ا� اﻟﻘ�ﻢ‬1 ‫ا� اﻟﻘ�ﻤﺔ‬
sequence 4, 2, 1). :
3 ‫ و‬5 ‫• ﻗﻢ ﺑ��ﺠﺎد ﺳﻼﺳﻞ ﻛﻮﻻﺗﺰ ﻟﻸﻋﺪاد‬
• Find the Collatz suit for numbers: 5 and 3 ‫اﻗ�ح ﺧﻮارزﻣ�ﺔ ﺗﻘﻮم بﻜﺘﺎبﺔ ﺳﻠﺴﻠﺔ ﻛﻮﻻﺗﺰ ﻣﻦ أﺟﻞ‬ ‫ت‬ •
• Propose an algorithm that generates the Collatz N ‫ﻃﺒ�� ﻣﻮﺟﺐ‬ ‫أي ﻋﺪد‬
‫ئ‬ ‫ي‬ ‫ت‬
suit for any given positive integer N. ‫ﺟﺰئ )داﻟﺔ( �ﻘﻮم بﻜﺘﺎبﺔ اﻟﺴﻠﺴﺔ وذﻟﻚ‬ ‫اﻗ�ح ﺑﺮﻧﺎﻣﺞ‬ •
‫ي‬
• Propose a subroutine (function) that generate (‫وﻏ� ﻋﻮد�ﺔ‬ ‫ن‬
‫بﻄ��ﻘﺘن )ﻋﻮد�ﺔ ي‬
‫ي‬
the suit with two ways (recursive and non-
recursive)
Collatz suite
For a positive integer number N (N>0) :
U0 = N
𝑈𝑈𝑛𝑛�
2 𝑖𝑖𝑖𝑖 𝑈𝑈𝑛𝑛 𝑖𝑖𝑖𝑖 𝑒𝑒𝑒𝑒𝑒𝑒𝑒𝑒 (‫)زوﺟﻲ‬
𝑈𝑈𝑛𝑛+1 = �
3𝑈𝑈𝑛𝑛 + 1 𝑖𝑖𝑖𝑖 𝑈𝑈𝑛𝑛 𝑖𝑖𝑖𝑖 𝑜𝑜𝑜𝑜𝑜𝑜 (‫)ﻓردي‬
University of 20 August 1955 - Skikda ‫ – ﺳﻜ�ﻜﺪة‬1955 ‫ أوت‬20 ‫ﺟﺎﻣﻌﺔ‬
Faculty of technology – Department of technology ‫كﻠ�ﺔ اﻟﺘﻜﻨﻮﻟﻮﺟ�ﺎ – ﻗﺴﻢ اﻟﺘﻜﻨﻮﻟﻮﺟ�ﺎ‬
1st year common core technology engineer ‫ﻣﺸ�ك ﻣﻬﻨﺪس ﺗﻜﻨﻮﻟﻮﺟ�ﺎ‬‫اﻟﺴﻨﺔ اﻷو� ﺟﺬع ت‬

Exercise 05: :‫اﻟﺘﻤ��ﻦ اﻟﺨﺎﻣﺲ‬


7 * 1 = 7
Write an algorithm who prints the 7 * 2 = 14 ‫ﻗﻢ بﻜﺘﺎبﺔ ﺧﻮارزﻣ�ﺔ ﺗﻘﻮم بﻄبﺎﻋﺔ ﺟﺪول‬
7 * 3 = 21 ‫ض‬
multiplication table for a given number, 7 * 4 = 28
‫ي ض‬
‫ ﻓﻤﺜﻼ ﻟﻮ‬.‫ﻣﻌن ﻧﻘﻮم ﺑ�دﺧﺎﻟﻪ‬ ‫اﻟ�ب ﻟﺮﻗﻢ‬
7 * 5 = 35
for example if we enter the number 7 7 * 6 = 42 :‫ ﻧﺘﺤﺼﻞ ﻋ� اﻟﻨت�ﺠﺔ اﻟﺘﺎﻟ�ﺔ‬7 ‫أدﺧﻠﻨﺎ اﻟﺮﻗﻢ‬
we get the following result: 7 * 7 = 49
7 * 8 = 56
7 * 9 = 63
7 * 10 = 70

Exercise 06: :‫اﻟﺘﻤ��ﻦ اﻟﺴﺎدس‬


:‫ﻗﻢ ﺑﺮﺳﻢ ﻣﺨﻄﻂ اﻟﺨﻮارزﻣ�ﺔ اﻟﺘﺎﻟ�ﺔ ﺛﻢ‬
Draw the flowcharts of this algorithm then:
‫ت‬
1. State the result it gives if we enter the ‫اﻟي ﺗﻘﺪﻣﻬﺎ إذا أدﺧﻠﻨﺎ‬‫ أذﻛﺮ اﻟﻨت�ﺠﺔ ي‬.1
value: 125 125 ‫اﻟﻘ�ﻤﺔ‬
‫ت‬
2. State the result it gives if we enter the ‫ أذﻛﺮ اﻟﻨت�ﺠﺔ ي‬.2
‫اﻟي ﺗﻘﺪﻣﻬﺎ إذا أدﺧﻠﻨﺎ‬
value: 547103 547103 ‫اﻟﻘ�ﻤﺔ‬
3. What is the purpose of the algorithm? ‫� وﻇ�ﻔﺔ اﻟﺨﻮارزﻣ�ﺔ؟‬ ‫ ﻣﺎ ي‬.3

start
m  0
input n
while n ≠ 0 do
r  n modulo 10
m  m*10 + r
n  n / 10
endWhile
print m
end

Exercise 07: :‫اﻟﺘﻤ��ﻦ اﻟﺴﺎﺑﻊ‬


For a given array T, propose algorithms that: :�� ‫ت‬
‫ اﻗ�ح ﺧﻮارزﻣ�ﺎت ﺗﻘﻮم بﻤﺎ ي‬T ‫بﺎﻋﺘبﺎر ﺟﺪول‬
• Find the biggest and the smallest value on it ‫أ�� ﻗ�ﻤﺔ و أﺻﻐﺮ ﻗ�ﻤﺔ داﺧﻞ اﻟﺠﺪول‬
‫• إ�ﺠﺎد ب‬
• Getting the sum and the mean ‫• ﺣﺴﺎب اﻟﻤﺠﻤ�ع و اﻟﻤﻌﺪل‬
• Find the three biggest items �‫أ�� ﺛﻼث ﻋﻨﺎ‬ ‫• إ�ﺠﺎد ب‬
• Sorting its elements in ascending order ‫• ﺗﺮﺗ�ﺐ ﻋﻨﺎ� اﻟﺠﺪول ﺗﺼﺎﻋﺪ�ﺎ‬
Exercise 08: :‫اﻟﺘﻤ��ﻦ اﻟﺜﺎﻣﻦ‬
Translate the algorithms in exercises 2, 3, 5 and �‫ ا‬6 ‫ و‬5 ،3 ،2 ‫ﻗﻢ تﺑ�ﺟﻤﺔ ﺧﻮارزﻣ�ﺎت اﻟﺘﻤﺎر�ﻦ‬
6 to program in C language. .C ‫ﺑﺮاﻣﺞ بﻠﻐﺔ اﻟـ‬

You might also like