Character pattern program -- Print large words using "X" characters

Click For Summary

Discussion Overview

The discussion revolves around creating a program that generates large representations of words using "X" characters, specifically focusing on the implementation in C++. Participants explore various approaches to generalize the program, including handling different languages such as Nepali, and the challenges associated with Unicode input.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant shares a C++ program that prints a specific letter pattern using "X" characters and seeks guidance on generalizing it.
  • Another participant suggests using ASCII banner text programs as alternatives but acknowledges a desire to improve programming skills through this project.
  • Some participants propose using 9x5 two-dimensional arrays to represent each letter, suggesting that this could simplify the code compared to complex conditional statements.
  • There is a discussion about the feasibility of adapting the program for the Nepali language, with concerns about the complexity of the characters and the need for larger arrays.
  • One participant questions how a program could handle Unicode input, expressing uncertainty about distinguishing between similar Nepali characters.
  • Another participant notes that using Unicode in C++ is advanced and mentions specific functions available in the Visual Studio C standard library for handling Unicode characters.
  • The raster method of producing banner scripts is introduced, with suggestions to find or generate dotted font character patterns for various display formats.

Areas of Agreement / Disagreement

Participants express differing opinions on the best approach to generalizing the program, with some favoring the use of arrays while others suggest sticking to the original method. The discussion on handling Unicode input remains unresolved, with no consensus on the best practices or methods.

Contextual Notes

Participants mention the need for a significant amount of manual work to create the character arrays and the potential complexity of implementing Unicode support, indicating limitations in their current understanding of these topics.

Who May Find This Useful

Individuals interested in programming, particularly in C++, those looking to improve their skills in handling character representations, and those exploring multilingual programming challenges may find this discussion beneficial.

shivajikobardan
Messages
637
Reaction score
54
I want to make a program that takes strings as input. eg: physicsforums. And writes that using x'es.
example c of physicsforums should look like this.
1686493243666.png

I've written the program for this.
Code:
#include <iostream>
using namespace std;
int main()
{
    int size;
    cout << "Enter the size of the pattern: ";
    cin >> size;

    for (int i = 0; i < size*2-1; i++)
    {
        for (int j = 0; j < size; j++)
        {
            if ((((i==0||i==2*size-2)&&j>1)||(i==1||i==2*size-3)&&(j==1||j==size-1))|| (j==0&&(i>1&&i<2*size-3)))
                cout << "X";
            else
                cout << " ";
        }
        cout << endl;
    }

    return 0;
}

But I want to generalize? Any guidance available?
 
Technology news on Phys.org
google: ascii banner text

There should be plenty of programs for you to copy'n'paste.
 
hmmm27 said:
google: ascii banner text

There should be plenty of programs for you to copy'n'paste.
I want to make that as a project to improve my programming skills though.
 
Sure, so what are your ideas on how to go about it ?
 
I'd like to do one for Nepali Language, but not sure if that's within my range of skills. About how idk. I'll listen to you guys and decide.
 
Okay, then which part of your "programming skills" are you trying to improve upon ?
 
shivajikobardan said:
I want to make a program that takes strings as input. eg: physicsforums. And writes that using x'es.
example c of physicsforums should look like this.
View attachment 327708
I've written the program for this.
Code:
#include <iostream>
using namespace std;
int main()
{
    int size;
    cout << "Enter the size of the pattern: ";
    cin >> size;

    for (int i = 0; i < size*2-1; i++)
    {
        for (int j = 0; j < size; j++)
        {
            if ((((i==0||i==2*size-2)&&j>1)||(i==1||i==2*size-3)&&(j==1||j==size-1))|| (j==0&&(i>1&&i<2*size-3)))
                cout << "X";
            else
                cout << " ";
        }
        cout << endl;
    }

    return 0;
}

But I want to generalize? Any guidance available?
IMO, generalization is the wrong way to go. The example letter, 'C', in the problem displays a large version of this letter in a 9 row by 5 column grid of 'X' characters and spaces.
Instead of using a complicated if statement, I would use 9 x 5 two-D arrays consisting of 1s and 0s, one for each letter. Given an input character, I would have the program look up the appropriate array in the data section and then use a nested for loop to print 'X' wherever the array contains 1, and a space where there is a 0.

A program like what I've described will have a very short code section, but a large section of data for the arrays, possibly an array of 9 by 5 arrays.

For starters, write a program that will print a large-form A, B, or C. You'll need to do a fair amount of work by hand using some graph paper to see how to fill in an array for each letter. You could do the same thing for the Nepali alphabet, but you might need to use larger array (10 x 10?) because the Nepali letters seem to have more curlicues than the Roman letters used in the English alphabet.
 
  • Like
Likes   Reactions: Merlin3189
Mark44 said:
Instead of using a complicated if statement, I would use 9 x 5 two-D arrays consisting of 1s and 0s, one for each letter. Given an input character, I would have the program look up the appropriate array in the data section and then use a nested for loop to print 'X' wherever the array contains 1, and a space where there is a 0.
Or use 9x5 arrays of characters, each position containing an 'X' or a ' ' (blank space).

If I were doing this myself, I'd use a std::vector of std::strings, each string containing a row of the 9x5 matrix. I stopped using C-style arrays in C++ probably 25 years ago.
 
Mark44 said:
IMO, generalization is the wrong way to go. The example letter, 'C', in the problem displays a large version of this letter in a 9 row by 5 column grid of 'X' characters and spaces.
Instead of using a complicated if statement, I would use 9 x 5 two-D arrays consisting of 1s and 0s, one for each letter. Given an input character, I would have the program look up the appropriate array in the data section and then use a nested for loop to print 'X' wherever the array contains 1, and a space where there is a 0.

A program like what I've described will have a very short code section, but a large section of data for the arrays, possibly an array of 9 by 5 arrays.

For starters, write a program that will print a large-form A, B, or C. You'll need to do a fair amount of work by hand using some graph paper to see how to fill in an array for each letter. You could do the same thing for the Nepali alphabet, but you might need to use larger array (10 x 10?) because the Nepali letters seem to have more curlicues than the Roman letters used in the English alphabet.
But How'd a computer program take unicode as an input? Is it possible? फिजिक्स फोरुम्स, this is nepali for physics forums. But how will a computer detect फि vs फ vs फो. you know any idea?
 
  • #10
Unfortunately, using Unicode in C++ appears to be a rather advanced topic. I tried a Google search for "c++ unicode string" and couldn't quickly find any simple descriptions.
 
  • #11
The raster method of producing banner script involves generating or finding a dotted font character pattern, as is used by dot-matrix or raster-scan displays. Those come in say, 5x8, 8x8 or 12x8 dot format.
There will be an LCD manufacturer who provides a dotted font data set for use with their displays. You might use one of those.

Search; "dotted font"
With; Nepali, Devanagari, Hindi, Ananda.

https://pijaeducation.com/arduino/l...r-custom-character-on-lcd-16x2-using-arduino/

http://fonthindi.blogspot.com/2014/05/dotted-hindi-font-for-complete-new-look.html
 
  • Like
Likes   Reactions: pbuk
  • #12
jtbell said:
Unfortunately, using Unicode in C++ appears to be a rather advanced topic. I tried a Google search for "c++ unicode string" and couldn't quickly find any simple descriptions.
There are several functions in the Visual Studio C standard library that can be used with Unicode characters, including wscanf_s and wprintf. Their headers are in the stdio.h or cstdio headers that can be included in a C++ program. I don't have any experience in working with Unicode characters, so can't say more than this.
There's some brief and not very helpful documentation of wscanf_s here -- https://learn.microsoft.com/en-us/c...s-scanf-s-l-wscanf-s-wscanf-s-l?view=msvc-170.
 
  • #13
Baluncore said:
The raster method of producing banner script involves generating or finding a dotted font character pattern, as is used by dot-matrix or raster-scan displays. Those come in say, 5x8, 8x8 or 12x8 dot format.
There will be an LCD manufacturer who provides a dotted font data set for use with their displays. You might use one of those.

Search; "dotted font"
With; Nepali, Devanagari, Hindi, Ananda.

https://pijaeducation.com/arduino/l...r-custom-character-on-lcd-16x2-using-arduino/

http://fonthindi.blogspot.com/2014/05/dotted-hindi-font-for-complete-new-look.html
I see Nepali=Hindi as everything is same. I'll have a look at it.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 75 ·
3
Replies
75
Views
6K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 23 ·
Replies
23
Views
3K