Sabtu, 26 Oktober 2013

Perulangan for membuat persegi

1.Tulis script

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
int main(){
printf("\xDB\xDB\ waone \xDB\xDB\ ");
printf("\n-----------\n");
int n;
for(n=1;n<=10;n++){
cout<<"*";
}
cout<<endl;
for(int i=1;i<=10;i++){
if(i==5||i==6){
cout<<" ";
}
else
cout<<"*";
}
cout<<endl;
for(int j=1;j<=10;j++){
if(j==4||j==5){
cout<<" ";
}
else if(j==6||j==7)
cout<<" ";
else
cout<<"*";
}
cout<<endl;
for(int k=1;k<=10;k++){
if(k==3||k==4){
cout<<" ";
}
else if(k==5||k==6)
cout<<" ";
else if(k==7||k==8)
cout<<" ";
else
cout<<"*";
}
cout<<endl;
for(int m=1;m<=10;m++){
if(m==2 || m==3){
cout<<" ";
}
else if(m==4 || m==5){
cout<<" ";
}
else if(m==6 || m==7){
cout<<" ";
}
else if(m==8 || m==9){
cout<<" ";
}
else
cout<<"*";
}
cout<<endl;
for(int q=1;q<=10;q++){
if(q==3||q==4){
cout<<" ";
}
else if(q==5||q==6)
cout<<" ";
else if(q==7||q==8)
cout<<" ";
else
cout<<"*";
}
cout<<endl;
for(int w=1;w<=10;w++){
if(w==4||w==5){
cout<<" ";
}
else if(w==6||w==7)
cout<<" ";
else
cout<<"*";
}
cout<<endl;
for(int r=1;r<=10;r++){
if(r==5||r==6){
cout<<" ";
}
else
cout<<"*";
}
cout<<endl;
int t;
for(t=1;t<=10;t++){
cout<<"*";
}
cout<<endl;
printf("\n \xDB\xDB\xDB\xDB\xDB\xDB\xDB\xDB\ \n");
getch();

}

maka hasilnya


Tidak ada komentar:

Posting Komentar