4. خامسا:المصفوفا إلستخدام أمثلةت
بأنواعھا المصفوفات لمعالجة برامج انشاء كيفية لتوضيح االمثلة من لمجمزعة الجزء ھذا فى سنتعرض.
برنامج1:وطباعة وحساب االلى الحاسب مادة فى الطالب من عدد درجات لقراءة برنامج انشئ
الدرجات ومتوسط مجموع.
الحل:
#include<iostream.h>
void main(void)
{
int degrees[25],i,n;
float sum,average;
cout<<”Enter number of students n please /n”;
cin>>n;
sum=0;
for(i=0;i<n;i++)
{
cout<<”Enter the degree of student no. “<<i<<”please n”;
cin<<degrees[i];
sum=sum+degrees[i];
}
average=sum/n;
cout <<” The average of degrees is “ <<average<<”n”;
}
5. برنامج2:بمقدار الموظفين رواتب لزيادة برنامج انشئ20%رواتبھم مقدار من.
الحل:
#include<iostream.h>
void main(void)
{
int salary[100],i,n;
float average;
cout<<”Enter number of employees n please /n”;
cin>>n;
for(i=0;i<n;i++)
{
cout<<”Enter the salary of employee no. “<<i<<”please n”;
cin<<salary[i];
salary[i]= salary[i]*(1.2);
cout<<”Salary after increasing= “<<salary[i]<<”n”;
}
}
برنامج3:
وطباعة أخري مربعة مصفوفة فى الناتج ووضع مربعتين مصفوفتين لقراءة برنامج انشئعلى الناتج
الشاشة:
6. الحل:
include<iostream.h>
void main(void)
{
int a[10][10],b[10][10],c[10][10],i,j,m,n;
cout<<”Enter number of rows and columns please m and nplease /n”;
cin>>m>>n;
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
cout<<”Enter the the elements of matrices a and b for row #”<<i<<”and col. #”<<j<<”
pleasen”;
cin>>a[i][j]<<b[i][j];
cout<<”The sum of the matrix is given by= “<<c[i][j]<<”n”;
}
}
برنامج3:
طالب اسم قراءة برنامج انشئnameالجملة مستخدما به رحب ثمnamewelcome
الحل:
# include<iostream.h>
#include<string.h>
void main(void)
{
char namr[80]