Professional Documents
Culture Documents
المحاضرة السادسة برمجة .محاضرة اليوم
المحاضرة السادسة برمجة .محاضرة اليوم
المحاضرة السادسة برمجة .محاضرة اليوم
}
array[index]=input;
for(int j=0;j<6;j++){
cout<<array[j];
}
cout<<endl;
return 0;
}
_________________________________________________________
اكتب برنامج الستبدال رقم في مصوفة برقم مدخل
#include <iostream>
using namespace std;
void addnumberToarray();
int main()
{
int array[5]={1,2,3,4,5},newvalu,input;
bool isfound=false;
cout<<"Enter The number to add:";
cin>>input;
cout<<"Enter The Location to add:";
cin>>newvalu;
for(int i=0;i>=5;i++){
if(input==array[i]){
array[i]=newvalu;
isfound=true;
}
else
cout<<"The Number Is Not Found";
for(int j=0;j<6;j++){
cout<<array[j];
}
cout<<endl;
return 0;
}
______________________________________________________
اكتب برنامج لجمع عناصر القطر الثانوي لمصفوفة ثنائية البعد
#include <iostream>
using namespace std;
int main()
{
int a[3][3]={{5,6,2},{8,6,4},{3,1,7}};
int i,j,sum=0;
for(i=0;i<3;i++)
for(j=0;j<3;j++)
{
if(i!=j && j>i)
// sum+=
a[i][j]=0;
cout<<a[i][j]<<endl;
}
return 0;
}
_______________________________________________________________