#include <stdio.h>
#include <stdlib.h>
#include "genlib.h"
#include "simpio.h"
#include "strlib.h"
#include "concol.h"
#include <iostream>
#include <string>
#include <windows.h>
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;
int reverse (int ending);
static void InitScreen(void);
void gotoXY(int x,int y);
void gotoXY(int x,int y)
{
CursorPosition.X = x;
CursorPosition.Y = y;
SetConsoleCursorPosition(console,CursorPosition);
}
int reverse (int ending)
{
int reverse;
reverse=0;
while (ending!=0)
{
reverse = reverse * 10;
reverse = reverse + ending%10;
ending = ending/10;
}
return(reverse);
}
static void InitScreen(void)
{
string spac_init;
int iij;
setcolor(yellow,red);
spac_init="";
for(iij=0;iij<24000;iij++)
{
spac_init=Concat(" ",spac_init);
}
printf ("%s",spac_init);
gotoXY(0,0);
}
main()
{
InitScreen();
int n,i,j,width,num,mun,nmn,loop,loop1,ending,beginning_int,muner;
string answer,count_str,beginning;
char mun_str[100];
char loop_str[100];
start:
printf ("Number?\n\n > ");
n=GetInteger();
printf ("\n\n\n\n");
if ((n<1)||(n>9))
{
printf ("Number cannot be greater than 10 or less than 1. Please retry.\n");
goto start;
}
width=(2*n)-1;
answer="";
beginning="";
answer="";
loop=0;
loop1=0;
num=0;
mun=1;
j=n;
for(i=1;i<=width;i++)
{
if (i<=n)
{
itoa(mun,mun_str,10);
loop++;
for (nmn=1;nmn<=width-num;nmn++)
{
answer=Concat(answer,mun_str);
}
if (i==1)
{goto end;}
for (muner=1;muner<loop;muner++)
{
loop1++;
itoa(loop1,loop_str,10);
beginning=Concat(beginning,loop_str);
}
end:
beginning_int=atoi(beginning);
ending=reverse(beginning_int);
num=num+2;
mun++;
j=j-1;
if (i==1)
{printf ("%s\n",answer);}
else{
printf ("%d%s%d\n",beginning_int,answer,ending);}
goto SaveCopy;
endSaveCopy:
loop1=0;
answer="";
beginning="";
}
else
{break;}
}
goto PrintLast;
SaveCopy:
int beginning1,beginning2,beginning3,beginning4,beginning5,beginning6,beginning7,beginning8;
string answer1,answer2,answer3,answer4,answer5,answer6,answer7,answer8;
int ending1,ending2,ending3,ending4,ending5,ending6,ending7,ending8;
if(j==1){
beginning1=beginning_int;
answer1=answer;
ending1=ending;
}
else if(j==2){
beginning2=beginning_int;
answer2=answer;
ending2=ending;
}
else if(j==3){
beginning3=beginning_int;
answer3=answer;
ending3=ending;
}
else if(j==4){
beginning4=beginning_int;
answer4=answer;
ending4=ending;
}
else if(j==5){
beginning5=beginning_int;
answer5=answer;
ending5=ending;
}
else if(j==6){
beginning6=beginning_int;
answer6=answer;
ending6=ending;
}
else if(j==7){
beginning7=beginning_int;
answer7=answer;
ending7=ending;
}
else if(j==8){
beginning8=beginning_int;
answer8=answer;
ending8=ending;
}
goto endSaveCopy;
PrintLast:
int njm;
for(njm=1;njm<n;njm++)
{
if(njm==1)
{if(n==2)
{printf("%s\n",answer1);}
else {printf ("%d%s%d\n",beginning1,answer1,ending1);}}
else if(njm==2)
{if(n==3)
{printf("%s\n",answer2);}
else{printf ("%d%s%d\n",beginning2,answer2,ending2);}}
else if(njm==3)
{if(n==4)
{printf("%s\n",answer3);}
else{printf ("%d%s%d\n",beginning3,answer3,ending3);}}
else if(njm==4)
{if(n==5)
{printf("%s\n",answer4);}
else{printf ("%d%s%d\n",beginning4,answer4,ending4);}}
else if(njm==5)
{if(n==6)
{printf("%s\n",answer5);}
else{printf ("%d%s%d\n",beginning5,answer5,ending5);}}
else if(njm==6)
{if(n==7)
{printf("%s\n",answer6);}
else{printf ("%d%s%d\n",beginning6,answer6,ending6);}}
else if(njm==7)
{if(n==8)
{printf("%s\n",answer7);}
else{printf ("%d%s%d\n",beginning7,answer7,ending7);}}
else if(njm==8)
{if(n==9)
{printf("%s\n",answer8);}
else{printf ("%d%s%d\n",beginning8,answer8,ending8);}}
}
goto endPrintLast;
endPrintLast:
getchar();
}
Post a Comment for "Apakah ini sebuah tanda tanya ?"