- تاريخ التسجيل
- 14 سبتمبر 2012
- المشاركات
- 2,834
- المجموعة
- ذكر
- الدفعة الدراسية
- 2012
- الكلية
- كلية تقنية المعلومات
- التخصص
- CS - متقاعد
int main()
{
trapezoid(0,9);
return 0 ;
}
[LEFT]void main {
int s,e;
cout<<"enter start";
cin>>s;
cout<<"enter end";
cin>>e;
trapezoid(s,e);
}
[/LEFT]
مثل ما وضحت نقاء , بكون ثابت البرنامج الى 0 و 9 يدخلون عالفنكشن
تقدرين تخلينه متغير بحيث اليوزر يدخل قيم ستارت و اند
استخدمت الفويد مين لأن مجرد الآوتبوت طباعة ما بترجع الفنكشن قيمةكود:[LEFT]void main { int s,e; cout<<"enter start"; cin>>s; cout<<"enter end"; cin>>e; trapezoid(s,e); } [/LEFT]
و يصير بعد بالانتجر مين مثل ما وضحت نقاء
بس السؤال يبون بال nested loop
كود:int main() { trapezoid(0,9); return 0 ; }
حطي دا خيو " وَ ان شاء الله بـ‘يضبط ^^
#include<iostream>
using namespace std;
void trapezoid(int start, int end)
{
int r,c;
for(r=start; r<=end;r++)
{
for(c=1 ; c<=r;c++)
cout<<r;
cout<<endl;}
}
int main() {
int s,e;
cout<<"enter start";
cin>>s;
cout<<"enter end";
cin>>e;
trapezoid(s,e);
system("pause");
return 0;
}
كود:void main() { int r,c; cin>>r>>c; for (int i=r;i>0;i--){ for (int j=0;j<=c;j++) cout<<i+j; cout<<endl;} }
كود:#include<iostream> using namespace std; void trapezoid(int start, int end) { int r,c; for(r=start; r<=end;r++) { for(c=1 ; c<=r;c++) cout<<r; cout<<endl;} } int main() { int s,e; cout<<"enter start"; cin>>s; cout<<"enter end"; cin>>e; trapezoid(s,e); system("pause"); return 0; }
صار لييي بس لازم من 0 الى 9 جيفة اسويه
كود:void main() { int r,c; cin>>r>>c; for (int i=r;i>0;i--){ for (int j=0;j<=c;j++) cout<<i+j; cout<<endl;} }
#include<iostream>
using namespace std;
void DisplayGrid ()
{
int r,c;
cin>>r>>c;
for (int i=r;i>0;i--){
for (int j=0;j<=c;j++)
cout<<i+j;
cout<<endl;}
}
int main()
{
DisplayGrid ();
system("pause");
return 0;
}

that takes as parameters number of rows and number of columns in the gride
void DisplayGrid ()
void DisplayGrid (int r , int c )
void DisplayGrid (int r , int c )
{
for (int i=r;i>0;i--){
for (int j=0;j<=c;j++)
cout<<i+j;
cout<<endl;}
}
int main()
{
int row, column;
cin>>row>>column;
DisplayGrid (row,column);
system("pause");
return 0;
}
كود:#include<iostream> using namespace std; void trapezoid(int start, int end) { int r,c; for(r=start; r<=end;r++) { for(c=1 ; c<=r;c++) cout<<r; cout<<endl;} } int main() { int s,e; cout<<"enter start"; cin>>s; cout<<"enter end"; cin>>e; trapezoid(s,e); system("pause"); return 0; }
صار لييي بس لازم من 0 الى 9 جيفة اسويه
[LEFT]
if(int i=0;i<10;i++)
{
cout<< ....... ;
cin>> s>> e;
for(int j=0;j<1;j++)
{
if( ...... )
call functin
break;
}[/LEFT]
cout
cin
while(!(s>0||e<9))
{
cout
cin
}
call function
[TABLE]
[TR]
[TD]
[/TD]
[/TR]
[/TABLE]
[TABLE]
[TR]
[TD] [CENTER][CENTER]Output[/CENTER][/CENTER]
[/TD]
[/TR]
[/TABLE]
[FONT="]void f(double &r, double v)[/FONT] [FONT="]{[/FONT]
[FONT="] r+=2;[/FONT]
[FONT="] v+=2;[/FONT]
[FONT="]}[/FONT]
[FONT="]int main()[/FONT]
[FONT="]{[/FONT]
[FONT="] double x=10, y=20;[/FONT]
[FONT="] f(x,y);[/FONT]
[FONT="] cout<<x<<endl<<y;[/FONT]
[FONT="]}[/FONT]
الفنكشن لازم يكون داخلها 2 parameters
HTML:void DisplayGrid (int r , int c )
و تعدلين الفنكشن تشيلين منها int r,c و cin
HTML:void DisplayGrid (int r , int c ) { for (int i=r;i>0;i--){ for (int j=0;j<=c;j++) cout<<i+j; cout<<endl;} }
, و تحطين cin في المين
HTML:int main() { int row, column; cin>>row>>column; DisplayGrid (row,column); system("pause"); return 0; }
بالتوفيق
في هذا السؤال يمبونه نكتب الآوت بت بس اني مو عارفة لانه مافي returnكود:[/LEFT] [TABLE] [TR] [TD][LEFT] [/LEFT] [CENTER][LEFT]Output[/LEFT] [/CENTER] [/TD] [/TR] [/TABLE] [LEFT] [FONT=&]void f(double &r, double v)[/FONT] [FONT=&]{[/FONT] [FONT=&] r+=2;[/FONT] [FONT=&] v+=2;[/FONT] [FONT=&]}[/FONT] [FONT=&]int main()[/FONT] [FONT=&]{[/FONT] [FONT=&] double x=10, y=20;[/FONT] [FONT=&] f(x,y);[/FONT] [FONT=&] cout<<x<<endl<<y;[/FONT] [FONT=&]}[/FONT][/LEFT]
12
20
void displayPattern(int n){
int y;
for (int i = 1; i<= n ; i++ ){
y= i;
for ( int j = 1; j <= i ; j++){
cout<<y--;
}
cout<<endl;
}
}
}
#include <iostream>
using namespace std;
void displayPattern(int n);
int main () {
int n ;
cin>>n;
displayPattern(n);
system ("pause");
return 0;
}
void displayPattern(int n){
int y;
for (int i = 1; i<= n ; i++ ){
y= i;
for ( int j = 1; j <= i ; j++){
cout<<y--;
}
cout<<endl;
}
}