برمجة مهيكلة 💻تقنية معلومات⌨
Open in Telegram
تقنية معلومات مستوى ثاني ( برمجة مهيكلة ) https://t.me/pro_st_ru_ab_o
Show more282
Subscribers
+1424 hours
+1097 days
+45730 days
Posts Archive
نسخ ملف إلى ملف آخر مع معرفة عدد عناصر الملف
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int i = 0, k = 1;
ofstream out("letter.txt"); //الكتابة في الملف
out << "Programming final exam" << endl;
out << "Programming final exam";
out.close(); //إغلاق الملف.
ofstream outt("temp.txt");
char arr;
ifstream infile("letter.txt"); //فتح الملف
while (!infile.eof())
{
infile.get(arr);
cout << arr; //طباعة محتوى الملف
i++; //عد عدد الأحرف في الملف
if (arr == '\n')
k++; //عد عدد الأسطر في الملف
outt << arr; //نسخ الملف إلى ملف آخر
}
infile.close();
outt.close();
cout << endl;
cout << "count of letter=" << i << endl;
cout << "count of line=" << k << endl;
cout << "♤♡♤♡♤♡♤♤♤♤♤♤♤♤♤♤♤" << endl;
char ar;
ifstream infie("temp.txt"); //فتح الملف
while (!infie.eof())
{
infie.get(ar);
cout << ar; //طباعة محتوى الملف
}
infie.close();
}
رسم شكل بإستخدام دالة الإستدعاء الذاتي
#include<iostream>
using namespace std;
void f(int n)
{
if(n<0)
return;
f(n-1);
for(int i=0;i<n;i++)
cout<<"=";
cout<<endl;
}
int main()
{
f(4);
}
هذا البرنامج يقوم بالآتي :
١-دالة تقوم بطباعة النص
٢-دالة تقوم بعد عدد الأحرف
٣-دالة تقوم بحذف حرف من النص
٤-دالة تقوم بعد عدد الكلمات في النص
٥-دالة تقوم بحذف كلمة من النص
#include <iostream>
using namespace std;
void printstring(char *po)
{
for (int i = 0; *(po + i) != '\0'; i++)
{
cout << *(po + i); // طباعة النص
}
cout << endl;
}
int countchar(char *po, char ch)
{
int x = 0;// عدد يقوم بعد عدد الأحرف
for (int i = 0; *(po + i) != '\0'; i++)
{
if (*(po + i) == ch)
x++;
}
return x;
}
char *deletechr(char *po, char ch)
{
int j = 0;// دالة تقوم بحذف حرف من النص
for (int i = 0; *(po + i) != '\0'; i++)
{
if (*(po + i) != ch)
{
*(po + j) = *(po + i);
j++;
}
}
*(po + j) = '\0';
return po;
}
int countword(char *po)
{
int x = 1;// عداد يقوم بعد عدد الكلمات في النص
for (int i = 0; *(po + i) != '\0'; i++)
{
if (*(po + i) == ' ')
x++;
}
return x;
}
char deleteword(char *po, const char *del)
{
int z = strlen(del);// دالة تقوم بحذف كلمة محددة في نص معين
for (int i = 0; *(po+i) != '\0'; i++)
{
int found = 1;
for (int j = 0; j < z; j++)
{
if (*(po+i + j) != *(del+j))
{
found = 0;
break;
}
}
if (found)
{
for (int k = i; k < strlen(po); k++)
{
*(po+k)= *(po+k + z);
}
i--;
}
}
}
int main()
{
char str[] = "programming final exam";
printstring(str);
char ch = 'p';
cout << countchar(str, ch) << endl;
char *temp = deletechr(str, ch);
printstring(temp);
cout<<countword(str)<<endl;
char strtemp[] = "final";
deleteword(str, strtemp);
printstring(str);
}
Discrete - دسكريت
https://youtube.com/playlist?list=PLd2pEan0ZG_Y59xY-E1xo9YB27zmYwmIx&si=DLNVV6256hx596E6
هذا الكورس لمادة / الرياضيات المتقطعة
يتم فيه شرح ملزمة الدكتورة / هدى الشيخ . كامل"
