About


Saturday, October 5, 2013


// Program: diamond.cpp
// Author: James Conway
// Date: 10/09/02
// Desc: A basic diamond script.


#include <iostream>
using namespace std;

int main()
{
int x,y,num=20;
        char symbol;

cout << "Enter a single character> ";                 // Prompt for character
cin>>symbol;                                                     // Stores character

system("cls");                                                   // Clears screen


for(x = 1; x <= num / 2 + 1; x++)                                // Start top half of diamond
{
for(y = -20; y <= num - x; y++)
{
cout << ' ';                                     // Offset diamond to center
}

for(y = 1; y <= 2*x - 1; y++)
{
cout <<symbol;                                   // Prints symbol
}

cout << endl;                                                    // End line
}                                                                // End top half of diamond


for (x= num / 2 ; x >= 1 ; x--)                                  // Start bottom half of diamond
{
for(y = -20; y <= num - x; y++)
{
cout << ' ';                                     // Offset diamond to center
}

for(y = 1; y <= 2*x- 1; y++)
{
cout << symbol;                                  // Prints symbol
}

cout << endl;                                                    // End line
}                                                                // End bottom half of diamond

return 0;                                                        // Return 0

}

Title: Diamond Script
Description: A basic diamond script.
This file came from Planet-Source-Code.com...the home millions of lines of source code
You can view comments on this code/and or vote on it at: http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=5121&lngWId=3

The author may have retained certain copyrights to this code...please observe their request and the law by reviewing all copyright conditions at the above URL.


0 komentar:

Post a Comment

NO SARA
NO ribut
dan no coment :D