根据通过扫描仪输入的数据制作矩阵“图形”

时间:2018-09-04 12:50:13

标签: java matrix

当用户输入一年中所有12个月的薪水时,我需要制作类似图形的矩阵。 Simplegraph将打印输出,将输入的薪水四舍五入到最接近的1000。

具体来说,我的输出需要如下图所示。例如:如果用户输入的值介于1501和2500之间,则将其舍入为2000。 我已经弄清楚了如何对这些值取整,但是我不知道如何在指定的月份中为正确的值放置一个X

我想我需要将值保存在数组中。但是,如果将它们保存在数组中,我将无法弄清楚如何将它们放置在适当的月份。

Example Graph

2 个答案:

答案 0 :(得分:0)

数组中每月有一个条目?

在循环和创建矩阵时,只有类似

的方法
for y
    for x
        if(shouldPutX(x,y,months))
            System.out.print("X")
        else
            System.out.print(" ")

shouldPutX(x,y,months){
    int monthVal = month[x-1]
    if monthVal should be rounded to this line
        return true
    else
        return false
}

答案 1 :(得分:0)

<button 
  type="button" 
  class="btn LG_btn-grey animated" 
  (click)="onSubmitResendEmail(user.email, $event);sharedService.getCurrentURL()">
  <app-icons-renderer 
    [name]="'sendEmail'">
  </app-icons-renderer>
</button>

我现在需要的是如何制作表格/矩阵

相关问题