-
#include
-
int main() {
-
char prnt = '*';
-
int i, j, k, s, p, r, nos = 7;
-
for (i = 1; i <= 5; i++) {
-
for (j = 1; j <= i; j++) {
-
if ((i % 2) != 0 && (j % 2) != 0) {
-
} else if ((i % 2) == 0 && (j % 2) == 0) {
-
} else {
-
}
-
}
-
for (s = nos; s >= 1; s--) { // for the spacing factor
-
}
-
for (k = 1; k <= i; k++) {
-
//Joining seperate figures
-
if (i == 5 && k == 1) {
-
continue;
-
}
-
if ((k % 2) != 0) {
-
} else {
-
}
-
}
-
-
nos = nos - 2; // space control
-
}
-
nos = 1;
-
// remaining half..
-
for (p = 4; p >= 1; p--) {
-
for (r = 1; r <= p; r++) {
-
if ((p % 2) != 0 && (r % 2) != 0) {
-
} else if ((p % 2) == 0 && (r % 2) == 0) {
-
} else {
-
}
-
}
-
for (s = nos; s >= 1; s--) {
-
}
-
for (k = 1; k <= p; k++) {
-
if ((k % 2) != 0) {
-
} else {
-
}
-
}
-
nos = nos + 2; // space control
-
-
}
-
return 0;
C #
Hi convert this program in C #..
Suthish NairPosted Oct 12, 2010, 3:58 AM
manoj kumarPosted Oct 11, 2010, 3:29 AM
You can ckeck my code...
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication6
{
class Program
{
static void Main(string[] args)
{
char prnt = '*';
int i, j, k, s, p, r, nos = 7;
for (i = 1; i <= 5; i++)
{
for (j = 1; j <= i; j++)
{
if ((i % 2) != 0 && (j % 2) != 0)
{
Console.WriteLine("%3c", prnt);
}
else if ((i % 2) == 0 && (j % 2) == 0)
{
Console.WriteLine("%3c", prnt);
}
else
{
Console.WriteLine(" ");
}
}
for (s = nos; s >= 1; s--)
{ // for the spacing factor
Console.WriteLine(" ");
}
for (k = 1; k <= i; k++)
{
//Joining seperate figures
if (i == 5 && k == 1)
{
continue;
}
if ((k % 2) != 0)
{
Console.WriteLine("%3c", prnt);
}
else
{
Console.WriteLine(" ");
}
}
Console.WriteLine("\n");
nos = nos - 2; // space control
}
nos = 1;
// remaining half..
for (p = 4; p >= 1; p--)
{
for (r = 1; r <= p; r++)
{
if ((p % 2) != 0 && (r % 2) != 0)
{
Console.WriteLine("%3c", prnt);
}
else if ((p % 2) == 0 && (r % 2) == 0)
{
Console.WriteLine("%3c", prnt);
}
else
{
Console.WriteLine(" ");
}
}
for (s = nos; s >= 1; s--)
{
Console.WriteLine(" ");
}
for (k = 1; k <= p; k++)
{
if ((k % 2) != 0)
{
Console.WriteLine("%3c", prnt);
}
else
{
Console.WriteLine(" ");
}
}
nos = nos + 2; // space control
Console.WriteLine("\n");
}
Console.ReadLine();
}
}
}
Suthish NairPosted Oct 10, 2010, 2:11 PM
did you tried before posting here?