الخوارزميات
مجموعة من التراكيب الرياضية والمنطقية والتي في النهاية تهدف لحل مشكل أو تحسين الأداء لمنتج أو طريقة المعالجة، الخوارزميات في علم الحاسوب هي مجموعة من التعليمات الواضحة التي يتم تنفيذها واحدة تلو الآخرى لحل مشكلة ما، واللفظ نسبة لعالم الرياضيات محمد بن موسى الخوارزمي.
The outlines of this lecture:
- Memory Addresses in Computer
- Definition of Pointers
- Access to Pointer Value
- star and & Operators
- Passing Pointer as Parameters
- Pointers with Constants
- Pointers with String
- Arrays of Pointers
- cString library
- Exercise
In this lecture, I present concept of arrays in C ++ , I cover :
- Arrays defination
- Initializing arrays
- Input and output with arrays
- Examples of arrays
- Histogram using arrays
- Calculate the frequency of dice
- Calculate the frequency of characters in a string
- Static arrays
- Arrays as arguments
- Two-dimensional arrays
- Files and Streams
- Sequential Files
- Write and Read to Sequential Files
- Random Files
- Write and Read to Random Files
- Full Examples and Exercise
The outlines of this lecture:
- Memory Addresses in Computer
- Definition of Pointers
- Access to Pointer Value
- star and & Operators
- Passing Pointer as Parameters
- Pointers with Constants
- Pointers with String
- Arrays of Pointers
- cString library
- Exercise
In this lecture, I present concept of arrays in C ++ , I cover :
- Arrays defination
- Initializing arrays
- Input and output with arrays
- Examples of arrays
- Histogram using arrays
- Calculate the frequency of dice
- Calculate the frequency of characters in a string
- Static arrays
- Arrays as arguments
- Two-dimensional arrays
- Files and Streams
- Sequential Files
- Write and Read to Sequential Files
- Random Files
- Write and Read to Random Files
- Full Examples and Exercise
11. 11
int x;
x = 12;
int *ptr;
ptr = &x;
*ptr = 5; // changes the value
// at address ptr to 5
عامل استخدام
مختلف التشغيل
2000
12 5
x
3000
2000
ptr
12. 12
char ch;
ch = ‘A’;
char* q;
q = &ch;
*q = ‘Z’;
char* p;
p = q; // the right side has value 4000
// now p and q both point to ch
اخر مثال
4000
A Z
ch
5000 6000
4000 4000
q p
19. المؤشرات استخدام عند العمليات أولوية
Some C++ pointer operations
Precedence
Higher -> Select member of class pointed to
++ -- ! * new delete
Increment, Decrement, NOT, Dereference, Allocate, Deallocate
+ - Add Subtract
< <= > >= Relational operators
== != Tests for equality, inequality
Lower = Assignment
20. 20
تخصيص
الديناميكي
للمصفوفة
char *ptr; // ptr is a pointer variable that
// can hold the address of a char
ptr = new char[ 5 ];
// dynamically, during run time, allocates
// memory for 5 characters and places into
// the contents of ptr their beginning address
ptr
6000
6000
21. 21
للمصفوفة الديناميكي تخصيص
#include <iostream>
#include <cstring>
int main() {
char *ptr ;
ptr =new char[5];
strcpy(ptr,"Bye" ); // a pointer can be subscripted
std::cout<< ptr[1] ;
return 0;}
ptr
6000
6000 ‘B’ ‘y’ ‘e’ ‘0’
22. 22
char *ptr ;
ptr = new char[ 5 ];
strcpy( ptr, “Bye” );
ptr[ 1 ] = ‘u’;
delete ptr; // deallocates array pointed to by ptr
// ptr itself is not deallocated, but
// the value of ptr is considered unassigned
ptr
?
للمصفوفة الديناميكي تخصيص
ptr
6000
‘B’ ‘y’ ‘e’ ‘0’
‘u’
23. 23
int* ptr = new int;
*ptr = 3;
ptr = new int; // changes value of ptr
*ptr = 4;
التالي المثل في يحدث ماذا
3
ptr
3
ptr
4