一个使用四个指针数组的程序 [英] a program using four arrays of pointers

查看:101
本文介绍了一个使用四个指针数组的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个程序,使用4个指向char的指针数组,称为article,noun,verb和preposition。程序应该通过按以下顺序从每个数组中随机选择一个单词来创建一个句子:文章,名词,动词介词,文章和名词。每个单词都被选中,它应该连接到一个大小足以容纳整个句子的数组中的前一个单词。单词应该用空格分隔。当输出最后一句时,它应该以大写字母开头并以句点结束。程序应该生成20个这样的句子。


我是什么意思我从这个陈述中得出的结果就是使用了4个指针数组。所以你可以帮我理解从哪里开始因为我没有想法。谢谢

i''m writing a program that is using 4 arrays of pointers to char,called article,noun,verb and preposition.the program should create a sentence by selecting a word at random from each array in the following order:article,noun,verb preposition,,article and noun.as each word is picked,it should be concatenated to the previous words in an array that is large enough to hold the entire sentence. the words should be separated by spaces.when the final sentence is output,it should start with a capital letter and end with a period.the program should generate 20 such sentences.

what i have deduced from this statement is that ill be using 4 arrays of pointers.so may you help me to have an idea of where to start because i don''t have an idea.thanks

推荐答案


我正在编写一个程序,它使用4个指向char的指针数组,称为文章,名词,动词和介词。程序应该创建通过按以下顺序从每个数组中随机选择一个单词的句子:文章,名词,动词介词,文章和名词。每个单词都被选中,它应该连接到一个足够大的数组中的前一个单词抓住整个句子。单词应该用空格分隔。当输出最后一句时,它应该以大写字母开头并以句点结束。程序应该生成20个这样的句子。


我是什么意思我从这个陈述中推断出,我会使用4个指针数组。所以你可以帮我理解从哪里开始,因为我没有想法。谢谢
i''m writing a program that is using 4 arrays of pointers to char,called article,noun,verb and preposition.the program should create a sentence by selecting a word at random from each array in the following order:article,noun,verb preposition,,article and noun.as each word is picked,it should be concatenated to the previous words in an array that is large enough to hold the entire sentence. the words should be separated by spaces.when the final sentence is output,it should start with a capital letter and end with a period.the program should generate 20 such sentences.

what i have deduced from this statement is that ill be using 4 arrays of pointers.so may you help me to have an idea of where to start because i don''t have an idea.thanks



你是一个非常新的语言?你为什么被困?


无论如何,我建议将问题简化为几个部分:

1.)生成/初始化指针数组

2.)从每个数组中获取1个值

3.)数组中的Genrate字符串

4.)将第一个字符和位置句点大写在最后
5.)存入大小为20的数组

6.)打印

7.)重复19次以上。


祝你好运

Are you an extremely new to the language? Why are you stucked?

At any rate, I would suggest simplifying the problem down into sections:
1.) Generate/Initialize array of pointers
2.) Get 1 value from each array
3.) Genrate string from pieces of array
4.) Capitalize first character and place period at the end
5.) Store into array of size 20
6.) Print
7.) Repeat 19 more times.

Good luck



你是一个非常新的语言?你为什么被困?


无论如何,我建议将问题简化为几个部分:

1.)生成/初始化指针数组

2.)从每个数组中获取1个值

3.)数组中的Genrate字符串

4.)将第一个字符和位置句点大写在最后
5.)存入大小为20的数组

6.)打印

7.)重复19次以上。


祝你好运
Are you an extremely new to the language? Why are you stucked?

At any rate, I would suggest simplifying the problem down into sections:
1.) Generate/Initialize array of pointers
2.) Get 1 value from each array
3.) Genrate string from pieces of array
4.) Capitalize first character and place period at the end
5.) Store into array of size 20
6.) Print
7.) Repeat 19 more times.

Good luck



这是我用c ++编程的第一年,但我现在知道它的基础但我现在的问题我们没有完成数组和指针,这就是为什么我被卡住了。

this is my first year programming in c++ but i now know the basics of it but my problem now is we haven''t done arrays and pointers that''s why i''m stucked.



这是我编程的第一年在c ++但我现在知道它的基础但我现在的问题是我们没有做数组和指针,这就是为什么我被困。
this is my first year programming in c++ but i now know the basics of it but my problem now is we haven''t done arrays and pointers that''s why i''m stucked.



嗯,那么我建议读一下数组和指针。这里有一些很好的链接。

数组和指针

更多阵列和指针

阅读第2.2节。该图显示了一个数组和一个指向数组的指针。


为了简化问题,尝试使用指针将4个单词组合在一起,然后将它们打印出来。完成后,请担心创建指针数组,选择4个单词并存储它们。


祝你好运

Kat

Well, then I would suggest reading about arrays and pointers. Here''s some good links.

Arrays and Pointers

More Arrays and pointers
Read section 2.2. The diagram shows an array and a pointer to an array.

To make the problem simplier, try combining just 4 words together by using pointers then printing them out. After you have done that, worry about creating the array of pointers, choosing the 4 words, and storing them.

Good luck
Kat


这篇关于一个使用四个指针数组的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆