生成英文字母表中的字母
我有作业要写,要求我编写一个程序来生成英语字母表的前 15 个字母。我无法删除并设置 15 个不同的变量或常量。这些字母必须显示在用户最初设置的许多列中。数字必须按列对齐。有人可以帮忙吗?列数最大为 7,最小为 1。
I have homework due that states that I need to write a program that generates the first 15 letters of the english alphabet. I can't delcare and set 15 different variables or constants. The letters must be displayed in a number of columns initially set by the user. the numbers have to be aligned in columns. Can anyone help? Maximum number of columns is 7 and the minimum is 1.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里有一些伪代码可以帮助您入门。阅读它,理解它,然后尝试实施它。
它的定位大约是你的家庭作业的水平(没有花哨的东西和最小的尴尬),并且应该很好地映射到 C 代码中。
作为此实现的一部分,您应该研究:
'a'
这样的字符常量实际上是伪装的整数。%
) 运算符以及它们在这里如何/为何有用。scanf
获取用户输入。putchar
用于输出字符。if
语句:-)Here's some pseudo-code to get you started. Read it, understand it, then try to implement it.
It's pitched at about the level of your homework (no fancy stuff and the smallest hint of awkwardness) and should map reasonably well into C code.
As part of this implementation, you should research:
'a'
are really integers in disguise.%
) operators and how/why they are useful here.scanf
.putchar
for outputting characters.if
statement :-)这里提示一下:
A的ASCII码是65,B是66,C是67等等。您可以从 65 开始循环执行 15 次迭代。
Here is a hint:
ASCII code of A is 65, B is 66, C is 67 and so on. You can do it in a loop starting from 65 and going on for 15 iterations.
这可以通过两个嵌套循环来完成,一个用于垂直,一个用于水平。由于数字的值是按顺序排列的,因此您可以每次增加字符的变量。
我不想放弃更多,除非另一个用户说我应该放弃。我已经提供了很多帮助,我相信你可以弄清楚剩下的事情。
如果您觉得需要更多帮助,我会尽量不提供太多帮助,但会进行更多解释。
This can be done with two nested loops, one for the vertical and one for the horizontal. since the numbers are in sequence in value you can increment the variable for the character each time.
I don't want to give away more than that unless another user says I should. I've already given a lot of help and I'm sure you can figure out the rest.
If you feel you need more help I'll try to not give too much but explain more.