Hello everyone...
I have the following problem and i have no idea how to do it.
Can anyone help?
Write a procedure that takes a string as its parameter and which prints out a pattern made out of the string. For example, given the string "XMAS", it would output the following:
X
MM
AAA
SSSS
29 1767
You might like to look under the Articles section for c/c++. I believ AdrianH has posted some tutorials how to make patterns from asterisks. I would imagine that would help you to get started, and give you an idea of how to create the pattern!
Hello everyone...
I have the following problem and i have no idea how to do it.
Can anyone help?
Write a procedure that takes a string as its parameter and which prints out a pattern made out of the string. For example, given the string "XMAS", it would output the following:
X
MM
AAA
SSSS
I am using C++ and compiler DevC++.
thanks
I am trying to find the tutorial that you are talking but i can't can you give me some info or the link please?
thnx
Hi,
You can write a function which takes the character to print and the position of the character and you can print the character that many number of times. <code removed as per posting guidelines>
Since this is small part i have posted the code....if it against posting guidelines the sorry about that and please remove it.
Raghuram
try here (cleverly titled something about asterix so you would automatically assume Goscinny and Udzero ;))
Hello everyone!
thank you for your replies..i tried by myself and i wrote the following piece of code. But i can't compile it. Can anyone tell me what is wrong with my code?
thnx - #include <iostream>
-
-
using namespace std;
-
int main()
-
{
-
-
int counter,i,y;
-
char text[30];
-
cout << "Please enter a string : ";
-
int couter =0;
-
while ((text[counter]!= '\n') && (counter<30)){
-
cin>> text[counter++];
-
}
-
for (i=0;i<counter; i++)
-
{
-
for(y=0;y<=i;y++)
-
{
-
cout << text[i];
-
}
-
cout << '\n' ;
-
}
-
}
try here (cleverly titled something about asterix so you would automatically assume Goscinny and Udzero ;))
Ehm,is there a problem with the title.
PS:I forgot to ask:
Can u,or someone else, please change it to asterisks?
Savage
To print this:
X
MM
AAA
SSSS
using an array just recognize that the number of times to display the character is the array element number + 1.
Just write an outer loop that counts from 0 to the end of the array
Then write an inner loops that runs from 0 to the count+1 of the outer loop. You display the character in this inner loop.
I am sorry but i don't understand you. I think that i have done what you suggest in my code. and still i don't understand why my code doesn't work.it seems ok to me.
Can you be more specific please...
thx
This code:
maybve should be
Here's what I did: -
char msg[] = "XMAS";
-
for(int i =0; i < 4; ++i)
-
{
-
for(int j = 0; j < i + 1;++j)
-
{
-
cout << msg[i];
-
}
-
cout <<endl;
-
}
-
which is what I think you meant to do.
Ehm,is there a problem with the title.
PS:I forgot to ask:
Can u,or someone else, please change it to asterisks?
Savage
NO problem with your title......Sorry, I thought you had concealed a joke in there (and I can't change it - i don't have my magic powers in here)
BTW: I'm terribly sorry, I gave AdrianH credit for that one......you can kill me next time.....
NO problem with your title......Sorry, I thought you had concealed a joke in there (and I can't change it - i don't have my magic powers in here)
BTW: I'm terribly sorry, I gave AdrianH credit for that one......you can kill me next time.....
NO problem!!
I did concealed a joke,but maybe someone finds it stupid..
Savage
You might like to look under the Articles section for c/c++. I believ AdrianH has posted some tutorials how to make patterns from asterisks. I would imagine that would help you to get started, and give you an idea of how to create the pattern!
No, that was Savage.
Adrian
NO problem!!
I did concealed a joke,but maybe someone finds it stupid..
Savage
Are you referring to the Asterix comix? I loved those. :)
Adrian
Are you referring to the Asterix comix? I loved those. :)
Adrian
U love asterix comics?
Are u on crack again?
Savage
U love asterix comics?
Are u on crack again?
Savage
No, why? :p They were great. Asterix, Obolix beating up all those Romans. And the names: - getafix (the druid)
- vitalstatistix and his wife impedimenta
- cacophonix (the bard)
- fullioautomatix (ironmonger)
- nhygenix (the fish monger)
- geriatrix (the old guy)
Take a look at them and tell me there not funny. lol :D
Adrian
No, why? :p They were great. Asterix, Obolix beating up all those Romans. And the names:- getafix (the druid)
- vitalstatistix and his wife impedimenta
- cacophonix (the bard)
- fullioautomatix (ironmonger)
- nhygenix (the fish monger)
- geriatrix (the old guy)
Take a look at them and tell me there not funny. lol :D
Adrian
Everything is funny when u are on crack.Just don't think that u can fly.
Savage
Everything is funny when u are on crack.Just don't think that u can fly.
Savage
I think that the crack joke is getting old Savage. Just drink your potion and beat up some Romans. ;)
Adrian
I think that the crack joke is getting old Savage. Just drink your potion and beat up some Romans. ;)
Adrian
Oo moving up to higher level..
Savage
Oo moving up to higher level..
Savage
That's what happens when your 100 points behind. :D ;)
Adrian
That's what happens when your 100 points behind. :D ;)
Adrian
We have yet to see about this..
Also u have joined 24 days before me :p
Savage
No, why? :p They were great. Asterix, Obolix beating up all those Romans. And the names:- getafix (the druid)
- vitalstatistix and his wife impedimenta
- cacophonix (the bard)
- fullioautomatix (ironmonger)
- nhygenix (the fish monger)
- geriatrix (the old guy)
Take a look at them and tell me there not funny. lol :D
Adrian
And impedimenta - (vitalstatistix's wife, ->took me a while for the penny to drop on that one, though)
Not forgetting some of the people they encounter on their journeys.....to me that was (is?) one of the charms of the Asterix comics, trying to decipher what the names of the characters actually meant.....
And impedimenta - (vitalstatistix's wife, ->took me a while for the penny to drop on that one, though)
Not forgetting some of the people they encounter on their journeys.....to me that was (is?) one of the charms of the Asterix comics, trying to decipher what the names of the characters actually meant.....
DeMan u too?
Savage
DeMan u too?
Savage
We are ganging up on ya. ;) Though we are WAY OT.
Adrian
We are ganging up on ya. ;) Though we are WAY OT.
Adrian
Conspiracy!!
Savage
Conspiracy!!
Savage
You just want to get your points up past mine. :p
Adrian
You just want to get your points up past mine. :p
Adrian
And u just want to keep me down.
:P
Savage
No TV in my house 'til I was 13 - I was virtually brought up by Asterix & Tintin - now both available in DVD format (although I think only about 6 Asterix's have been released)
No TV in my house 'til I was 13 - I was virtually brought up by Asterix & Tintin - now both available in DVD format (although I think only about 6 Asterix's have been released)
U are a big fan,aren't u?
Savage
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Michael Weir |
last post by:
I'm sure this is a very simple thing to do, once you know how to do it, but
I am having no fun at all trying to write utf-8 strings to a unicode file.
Does anyone have a couple of lines of code...
|
by: Eugene |
last post by:
I'm working on a program which needs to convert a string to various data
types. I created a function using string streams and templates to do just
that:
template<typename T>
bool...
|
by: Steve |
last post by:
Hi,
How can I convert a C++ string to an integer and then an integer back to
a string? Is there built-in support for this?
Thanks,
Steve
|
by: ferran |
last post by:
Hi, I'm trying to convert a string to a long double using streams but
for some reasing seems to give the wrong values, the idea is to do a
precise textual conversion without roundings or...
|
by: Tron Thomas |
last post by:
What does binary mode for an ofstream object do anyway? Despite which
mode the stream uses, operator << writes numeric value as their ASCII
representation.
I read on the Internet that it is...
|
by: rainmaker1234 |
last post by:
Its very simple in VC++. In the followeing code I have declared a
String, and a double than I am taking the string and converting it into
Double. getch() at the end is only to pause the screen so...
|
by: Chris |
last post by:
I'm reading up on streams and I have two articles that
seem to conflict with each other. One article describes
streams and lists a few of the major ones (FileStream,
Memory Stream, Network...
|
by: electrixnow |
last post by:
in MS VC++ Express I need to know how to get from one comma delimited
text string to many strings.
from this:
main_string = "onE,Two,Three , fouR,five, six "
to these:
string1 =...
|
by: v4vijayakumar |
last post by:
#include <string>
#include <iostream>
using namespace std;
int main()
{
string str;
str.resize(5);
str = 't';
|
by: KIRAN |
last post by:
Hi all,
can i split a C string like this?
char * p = "Hello \
World\n\r";
is this according to standard?
Any help or link to standard regarding the above doubt is
aprreciated...
Regards,
Kiran
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |