+ 2
How to print a square using gotoxy in c++?please help?
2 Respuestas
+ 20
for(int a=1;a <=n;a++){
for (int b=1;b <=n;b++)
System.out.print("*");
System.out.println("");
}
//hope u can use it easily ☺
//for hollow square , put condition if ( a==1||b==1||a==n||b==n) print "*"
else " "
+ 2
If you 'still' require a 'gotoxy()' solution :
int n; cin>>n; int sx=0,sy=0;
// sx = Starting Absicca.
// sy = Starting Ordinate.
for(int i=0;i<n;i++)
{
gotoxy( sx, sy+i ); cout<<"*";
gotoxy( sx+i, sy ); cout<<"*";
gotoxy( sx+n, sy+i ); cout<<"*";
gotoxy( sx+i, sy+n ); cout<<"*";
}