Question

In: Computer Science

// c# printing to cmd line // 1 im trying to pring thing1 thing1 is a...

// c# printing to cmd line

// 1 im trying to pring thing1 thing1 is a simple list with 2 elements [10,2]

// then i try to create a grid of zeroes

// and finally change 1 element of the grid to a 1. but none of this seems to work

using System;

namespace cmd_line_game_2
{


class Program
{

static void Main(string[] args)
{
int number_of_lines = 29;
int number_of_chars = 11;
int[] thing1 = new int[2] { 10, 2};
//int [] thing1 = { 10, 2 };
int [,] grid1 = new int[number_of_chars, number_of_lines];

Console.WriteLine("thing below");
Console.WriteLine(thing1); // this should print [10,2] but it doesnt
Console.ReadKey();

while (1 < 2)
{
for (int y = 0; y < number_of_lines; y++)
{
for (int x = 0; x < number_of_chars; x++)
{
grid1[x, y] = 0; // for each x and y fill up the grid with zeroes
  
}
}
grid1[thing1[0], thing1[1]] = 1; // then change this 1 co-ordinate of the grid to a 1
Console.WriteLine("grid below");
Console.WriteLine(grid1);
Console.ReadKey();

}
}
}
}

Solutions

Expert Solution

You can't simply pass an array as a parameter to console.writeline .

Changing this to :-

foreach (int element in thing1)
     Console.WriteLine(element);

would do the job.

Input and output are as below :-

Please up-vote the answer if you liked it. Feel free to ask for any explanation in comments.


Related Solutions

I need this code translated from C++ to Java. Im personally still trying to learn Java,...
I need this code translated from C++ to Java. Im personally still trying to learn Java, so if you can include screenshots of your IDE/output that would be helpful. Much appreciated! #include <iostream> #include <string> using namespace std; class pizza { public:    string ingrediants, address;    pizza *next;    pizza(string ingrediants, string address)    {        this->address = address;        this->ingrediants = ingrediants;        next = NULL;    } }; void enqueue(pizza **head, pizza **tail, pizza...
Im trying to figure out the errors as to why these test case will not work...
Im trying to figure out the errors as to why these test case will not work for myvector.h. The issue I have with these test cases is the fact that when I implement these test cases into a grader the program declares that it is not working. So I need help in myvector.h to make the test cases work for my function. myvector.h #pragma once #include // print debugging #include // malloc, free using namespace std; template class myvector {...
Coding in R Im trying to plot a histogram in R, and i know the basic...
Coding in R Im trying to plot a histogram in R, and i know the basic code for that, however, the code requires 2 plots coming from the same data set. for example, the voltage of an old process vs. a new process. is there any ways to seperate the 2 processes out from the data set to make 2 relative frequencyt histograms?
plz answer all of them. my test is due in a hour and im trying to...
plz answer all of them. my test is due in a hour and im trying to pass 1.Suppose that the average and standard deviation of the number of points scored in an NBA game per player are 17.06 and 6.42, respectively. Calculate an interval that is symmetric around the mean such that it contains approximately 68% of players scores. Assume that the points scored has a normal distribution. 2. The daily stock price for International Business Machines (IBM) historically has...
Im trying to solve a babking problem for an inline course, it says to prepare someones...
Im trying to solve a babking problem for an inline course, it says to prepare someones bank reconciliation, what should my final answer look like?
im trying to write a java code that take a matrix of vector and fine it's...
im trying to write a java code that take a matrix of vector and fine it's inverse (the the inverse in linear algebra) then multiple this matrix with a vector to fine other vector (matrix)-1 × ( vector ) = (vector)
Im trying to get a GUI interface in java where there is four text fields for...
Im trying to get a GUI interface in java where there is four text fields for the first name, last name, department, and phone number of employee in a program. Then also have a radio button below for Gender (Male/Female/Other) and a list for the Title (Mr./Ms./Mrs./Dr./Col./Prof.). At the very bottom of the frame there has to be buttons for printing, submitting and exiting but for whatever reason when I tried it nothing appears in the frame regardless of what...
The Merriweather Printing Company is trying to decide on the merits of constructing a new publishing...
The Merriweather Printing Company is trying to decide on the merits of constructing a new publishing facility. The project is expected to provide a series of positive cash flows for each of the next four years. The estimated cash flows associated with this project are as​ follows: Year Project Cash Flow 0           ​ ? 1 ​$760,000 2   420,000 3   310,000 4   470,000 If you know that the project has a regular payback of 2.6 years, what is the​ project's IRR?...
The Merriweather Printing Company is trying to decide on the merits of constructing a new publishing...
The Merriweather Printing Company is trying to decide on the merits of constructing a new publishing facility. The project is expected to provide a series of positive cash flows for each of the next four years. The estimated cash flows associated with this project are as​ follows: Year Project Cash Flow 0           ​ ? 1 ​$780,000 2   350,000 3   270,000 4   510,000 If you know that the project has a regular payback of 3 ​years, what is the​ project's IRR?...
Im trying to figure out how to draw this Now, in the innermost circle (0.1 m...
Im trying to figure out how to draw this Now, in the innermost circle (0.1 m radius), assume we found 8 species of plant. In the second smallest circle, we found 10 species. In the third smallest circle, we found 13 species. In the largest circle, we found 14 species. Note that when moving from the smallest circle to the next-smallest circle, we did NOT find 10 additional species...The 10 species in the second smallest circle includes the 8 found...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT