mardi 5 avril 2016

C++ More Diamonds - Pattern Edit

I try to write a code for diamond and i found more versions. But, I want to make something different. I want to make a loop to make other diamonds smaller and smaller but to keep the initial dimensions of the "array form" and the diamond corners, and in finally to have a little diamond with a cross.

*Please, leave a contact address to talk about this! Thanks.

Something ike this (whithout underscore):

___*___
___*___
___*___
*** ***
___*___
___*___
___*___

#include<iostream>
#include<cstdlib>
using namespace std;

int main()
{
int i=0, j=0,k=0, NUM=4;

for(k=0;k<3;k++){//to make diamond 3 times smaller NUM--
for(i=-NUM; i<=NUM; i++)
{
for(j=-NUM; j<=NUM; j++)
{
if( abs(i)+abs(j)==NUM) 
 { cout<<"*"; }
else { cout<<" ";}
}
cout<<endl;
}
cout<<endl;
NUM--;
}
return 0;
}

Aucun commentaire:

Enregistrer un commentaire