如何获得每行一位数...请帮助,初学者:( [英] How to get one digit per line...please help, beginner :(

查看:61
本文介绍了如何获得每行一位数...请帮助,初学者:(的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好....我对这整个Java环境都很陌生,并且已经厌倦了早期的家庭作业。这听起来很简单,但经过几个小时的工作后,我无法得到它给我正确的输出。问题要求我输入一个四位数字,然后需要每行输出一个数字,如下所示:


1

9

9

1


任何人都有任何想法?谢谢!

Hello all....I am brand new to this whole Java environment and have become stumped with an early homework assignment. It sounds simple enough, but after hours and hours of working on it I can''t get it to give me the correct output. The problem calls for me to enter a four digit number and the number then needs to be output one digit per line like so:

1
9
9
1

Anyone have any ideas? Thanks!

推荐答案

A-hah!这是一个经典的问题,通过知道这个数字是一个四位数字就可以变得更容易了。


考虑以下陈述(请原谅任何语法错误 - 自从我学习了C ++以来,已经有一段时间了,因为我一直在学习C ++):

A-hah! This is a classic problem, and it''s been made so much easier by knowing that the number is a four digit number.

Consider the following statements (Please excuse any syntax errors - it''s been a while since I did any Java, as I''ve been learning C++):

展开 | 选择 | 换行 | 行号



A-hah!这是一个经典的问题,通过知道这个数字是一个四位数字就可以变得更容易了。


考虑以下陈述(请原谅任何语法错误 - 自从我学习了C ++以来,已经有一段时间了,因为我一直在学习C ++):

A-hah! This is a classic problem, and it''s been made so much easier by knowing that the number is a four digit number.

Consider the following statements (Please excuse any syntax errors - it''s been a while since I did any Java, as I''ve been learning C++):

展开 | 选择 | 换行 | 行号


绝对没有!实际上,这完美地完成了任务。但是,每当我在编程类中遇到此问题(或类似问题)时,我们就无法使用字符串函数 - 我们必须将num保留为整数而不是其他任何东西。因此,我开发了上述解决方案。两者都同样有效。
Absolutely nothing! Indeed, this accomplishes the task perfectly well. However, whenever I received this problem (or similar ones) in my programming class, we were prevented from using string functions - we had to keep num as an integer and nothing else. Thus, I developed the solution above. Both work equally well.


这篇关于如何获得每行一位数...请帮助,初学者:(的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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