1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
// Star Rhombus.cpp : main project file.
#include <iostream>
#include <windows.h>
using namespace std;
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
int main()
{
int a,b,c,v,i,j,k,n;
cout<<"Triangle 1 :";
cin>>v;
cout<<endl;
cout<<"Triangle 2 :";
cin>>n;
cout<<endl;
for (i=n; i>=0; i--)
{
// Experiment with the colors, from 0 to 255
for(j=i; j>=0; j--)
cout<<" ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),176+i );
// Just insert the above, BEFORE you cout the asterisks
for(k=0; k<=n-i; k++)
cout<<"*";
for(k=0; k<n-i; k++)
cout<<"*";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15 );
// Sets it to black background, white text
cout<<endl;
}
for(a=0; a<=v; a++)
{
for(b=0; b<=a; b++)
cout<<" ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),(176+a) );
for(c=0; c>=(a-v); c--)
cout<<"*";
for(c=0; c<(v-a); c++)
cout<<"*";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),15 );
// Sets it back to black background, white text
cout<<endl;
}
return 0;
}
|