شباب كيف حالكم ,,,
اذا بفيت ارسم خط داخل duble-subscripeted array
يعني matrix ....
بحيث انه البرنامج المستخدم هو اللي يدخل قيمة (x1,y1) , (x2,y2)
راح تكون التيجة زي كذا
...................................++...
................................+++.....
.............................+++........
..........................+++...........
.......................+++..............
....................+++.................
.................+++....................
..............+++.......................
......... +++..........................
........+++.............................
.....+++................................
...++...................................
........................................
........................................
........................................
........................................
........................................
........................................
........................................
........................................
بعد المحاولت و brain storming (عصف الذهني) :)
عرفت اني ما اقدر راح اجيبها الا اذا عرفت السلوب (slop)
قانون السلوب y=y+dx/dy
بعد التطبيق طلع معاي زي كذا
#include<iostream>
#include<cmath>
using namespace std;
const int Rows = 20;
const int Columns = 40;
int main ()
{
int x1, x2, y1 , y2;
char dots[Rows][Columns];
int y,i,j;
double tempy;
double dx = x1 - x2;
double dy = y1 - y2;
char simple ='*';
tempy = y1;
cout << "Enter the value x1\n";
cin >> x1;
cout << "Enter the value y1\n";
cin >> y1;
cout << "Enter the value x2\n";
cin >> x2;
cout << "Enter the value y2\n";
cin >>y2;
for(i=0;i<Rows;i++)
{
for(j=0;j<Columns;j++)
{
if (abs(dx) > abs(dy))
{
for (int a=x1+1;a<=x2;a++)
tempy = tempy +dx/dy; // هنا حسبت السلوب
y = static_cast<int>(tempy+.5);
dots[Rows][Columns] = simple; // هنا التغير الى السمبل
cout << dots[j];
}
dots[j]= '.';
cout << dots[j];
}
cout<< endl;
}
return 0;
}شوفي ليا يا شباب ومشكورين مقدما
