如何添加另外两个循环以使输出包括原始系列的减法 [英] How do I add another two loops in order to make the output includes subtraction of the original series

查看:53
本文介绍了如何添加另外两个循环以使输出包括原始系列的减法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

分配是再创建2个循环。



首先,添加一个循环来通过从中减去1来更改数组的每个项目。例如,4将变为3,-1将变为-2等。



其次,添加一个循环以打印出变换后的数组项目。







The assignment is to create 2 more loops.

First, add a loop to change the each item of the array by subtracting 1 from it. For example, a 4 would become a 3, a -1 would become a -2, etc.

Second, add a loop to print out the array with its transformed items.



using System; 
using System.Collections.Generic; 
using System.Linq;
using System.Text; 
 
namespace Assignment09
{     
class Program 
{           static void Main(string[] args) { 
 
 
            int[] numbers = { 4, 5, 6, 1, 2, 3, -2, -1, 0 }; 
 
            int i = 0;           
  while (i < numbers.Length)             
{                 System.Console.WriteLine(numbers[i]); 
 
                i++;             } 
 
              Console.Write("Hit any key to close"); Console.ReadKey(true); 
 
     }   
  }

 }





什么我试过了:



我试图以另一种方式添加另外两个循环并且它一直给我错误,输出不会出来.. ...所以我需要帮助plzzz



What I have tried:

I tried to add another two loops in another way and it keeps giving me errors, the output won't come out..... so I need help plzzz

推荐答案

他们轻轻地提供了一个循环示例:复制它然后适应您的需要。

For实例



They gently provided a loop example: Copy it and then adapt to your needs.
For instance

i = 0;
while (i < numbers.Length)             
{                 
   numbers[i] = numbers[i] - 1;
   i++;             
}  



会做'减法'技巧。


would do the 'subtraction' trick.


这篇关于如何添加另外两个循环以使输出包括原始系列的减法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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