السلام عليكم
هذا برنامج ثاني شبيه بالاول اللي كتبته على هالرابط
تقريبا نفس السؤال
الاول راح يطلع لي شكل نصف معين تقريبا
مثل كذا
r
r s
r s t
r s t u
r s t u v
r s t u v w
r s t u v w x
r s t u v w x y
r s t u v w x y z
r s t u v w x y
r s t u v w x
r s t u v w
r s t u v
r s t u
r s t
r s
r
الثاني راح يطلع مربع لكن المربع
ال ضلعين متقابلين حرف
والضلعين المتقابلين حرف آخر
ان شاء الله فهمتوا علي<<<
مثل كذا تقريبا
مربع طبعا مو نفس الشكل هذ
r r r r r r r
s s
s s
s s
s s
s s
s s
s s
r r r r r r r
ياليت احد يشوف ايش الخطأ بهذا الكود
#include<iostream>
using namespace std ;
class alphabetic {
char ch;
public:
char a,b;
void setalpha()
{
cout<<"Enter an alphabetic:";
cin>>a;
cout<<endl;
}
char getalpha()
{
return a;
}
void printalpha()
{
for(int i=0;i<6;i++)
{
b=a;
for(int j=0;j<=i;j++,b++)
{
cout<<b;
}
cout<<endl;
}
for(int i=6;i>=0;i--)
{
b=a;
for(int j=0;j<=i;j++,b++)
{
cout<<b;
}
cout<<endl;
}}
void Print_Blank_Square(){
int side, rowPosition, size;
cout << "Enter the square side: ";
cin >> side;
size = side;
while ( side > 0 ) {
rowPosition = size;
while ( rowPosition > 0 ) {
if ( size == side || side == 1 || rowPosition == 1 ||
rowPosition == size )
cout << ch;
else
cout << ' ';
--rowPosition;
}
cout << '\n';
--side;
}
cout << endl;
}
};
int main (){
alphabetic alp;
int choice;
cout<<"_____MENU>>>\n";
cout<<"1:draw Daimond\n";
cout<<"2 : draw square\n";
cout<<"3 : exit\n";
cout<<"ENTER YOUR CHOICE";
cin>>choice;
while(choice!=3)
{
if(choice==1)
{
alp.setalpha();
alp.getalpha();
alp. printalpha();
}
if(choice==2)
{
alp.setalpha();
alp.getalpha();
alp.Print_Blank_Square();
}
cout<<"------ MENU ------\n";
cout<<" 1 : Draw Traingle\n";
cout<<" 2 : Draw square\n";
cout<<" 3 : Exit\n";
cout<<" ENTER YOUR CHOICE : ";
cin>>choice;
}
cout<<"Exit";
return 0;}