我在制作这个节目时遇到了一些问题。我需要做的是为我班上的一个项目。我需要做的是这样的:http://patorjk.com/software/taag/
我可以一次打印一个字母,但问题是我无法打印像“ABC”那样的东西,它将它们全部打印在同一个地方。所以,如果你们中的任何一个人能够帮助我,并告诉我应该如何做的印刷将是如此美好。
#include <iostream>
#include <string.h>
#include<windows.h>
#include <stdio.h>
using namespace std;
char A[4][12]={
" // ",
" // // ",
" /////// ",
"// //"};
char B[5][12]={
" ///// ",
" // // ",
" ///// ",
" // // ",
" ///// "};
char C[5][12]={
" ///// ",
" // ",
" // ",
" // ",
" ///// "};
char D[5][12]={
" ///// ",
" // // ",
" // // ",
" // // ",
" ///// "};
char E[5][12]={
" ///// ",
" // ",
" //// ",
" // ",
" ///// "};
char F[5][12]={
" ///// ",
" // ",
" //// ",
" // ",
" // "};
char G[5][12]={
" ///// ",
" // ",
"// /// ",
" // // ",
" ///// "};
char H[5][12]={
" // // ",
" // // ",
" /////// ",
" // // ",
" // // "};
char I[5][12]={
" ** ",
" // ",
" // ",
" // ",
" // "};
char J[5][12]={
" // ",
" // ",
" // ",
" // // ",
" //// "};
char K[5][12]={
" // // ",
" // // ",
" /// ",
" // // ",
" // // "};
int main()
{
int x, k = 0;
char a[999];
cin.get(a, 999);
x = strlen(a);
while (k < 6)
{
for (int i = 0; i <= x; i++)
{
if (a[i] == 'A')
cout << A[k] << endl;
if (a[i] == 'B')
cout << B[k] << endl;
if (a[i] == 'C')
cout << C[k] << endl;
if (a[i] == 'D')
cout << D[k] << endl;
if (a[i] == 'E')
cout << E[k] << endl;
if (a[i] == 'F')
cout << F[k] << endl;
if (a[i] == 'G')
cout << G[k] << endl;
if (a[i] == 'H')
cout << H[k] << endl;
if (a[i] == 'I')
cout << I[k] << endl;
if (a[i] == 'J')
cout << J[k] << endl;
if (a[i] == 'K')
cout << K[k] << endl;
}
k = k + 1;
}
return 0;
}
答案 0 :(得分:0)
我写了一个非常相似的程序,通过打印散列来打印大尺寸的整数。 这是程序:
/**
Author:- Mayukh Datta
**/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define H 7
#define W 8 //one extra room in the char array is required for storing '\0'
void main()
{
char num[11]; //here too one extra room is needed for the '\0'
char c; //for option
int i, j, k;
//declaring char 2D arrays and initializing with hash-printed digits
char zero[H][W]={" ##### ", //H=0
" # # ", //H=1
" # # ", //H=2
" # # ", //H=3
" # # ", //H=4
" # # ", //H=5
" ##### "},//H=6
one[H][W]={" # ",
" ## ",
" # ",
" # ",
" # ",
" # ",
" ##### "},
two[H][W]={" ##### ",
" # ",
" # ",
" ##### ",
" # ",
" # ",
" ##### "},
three[H][W]={" ##### ",
" # ",
" # ",
" ##### ",
" # ",
" # ",
" ##### "},
four[H][W]={" # ",
" # # ",
" # # ",
" ##### ",
" # ",
" # ",
" # "},
five[H][W]={" ##### ",
" # ",
" # ",
" ##### ",
" # ",
" # ",
" ##### "},
six[H][W]={" ##### ",
" # ",
" # ",
" ##### ",
" # # ",
" # # ",
" ##### "},
seven[H][W]={" ##### ",
" # ",
" # ",
" #### ",
" # ",
" # ",
" # "},
eight[H][W]={" ##### ",
" # # ",
" # # ",
" ##### ",
" # # ",
" # # ",
" ##### "},
nine[H][W]={" ##### ",
" # # ",
" # # ",
" ##### ",
" # ",
" # ",
" # "};
do
{
printf("Enter a number upto 10 digits:- ");
fflush(stdin);
gets(num);
if(strlen(num)>10)
printf("\nYou must enter a number upto 10 digits.\nTry again!\n");
else
{
printf("\n");
k=1;
j=0; //controls H of each digit
while(k<=7) //controls height
{
for(i=0;i<strlen(num);i++) //reads each digit
{
if(num[i]=='0')
printf("%s", zero[j]);
else if(num[i]=='1')
printf("%s", one[j]);
else if(num[i]=='2')
printf("%s", two[j]);
else if(num[i]=='3')
printf("%s", three[j]);
else if(num[i]=='4')
printf("%s", four[j]);
else if(num[i]=='5')
printf("%s", five[j]);
else if(num[i]=='6')
printf("%s", six[j]);
else if(num[i]=='7')
printf("%s", seven[j]);
else if(num[i]=='8')
printf("%s", eight[j]);
else if(num[i]=='9')
printf("%s", nine[j]);
}
printf("\n");
k++;
j++;
}
}
printf("\nEnter Y to continue:- ");
fflush(stdin);
scanf("%c", &c);
}while(c=='Y'||c=='y');
}
了解循环在我的程序中的工作方式。 链接:http://www.thecoducer.com/2017/08/printing-the-number-in-large-size.html