|
here's my code so far:
[STAThread]
static void Main(string[] args)
{
double [] testvals = new double [14];
testvals [0] = 89;
testvals [1] = 95;
testvals [2] = 72;
testvals [3] = 83;
testvals [4] = 99;
testvals [5] = 54;
testvals [6] = 86;
testvals [7] = 75;
testvals [8] = 92;
testvals [9] = 73;
testvals [10] = 79;
testvals [11] = 75;
testvals [12] = 82;
testvals [13] = 73;
}
static double [] calc_avg (double []testvals)
{
double [] avgerage = new double [14];
for(int i = 0; i<14; i++)
{
average[i] = testvals[i]/14;
}
return average;
}
static double [] variance (double [] calc_avg, double []testvals)
{
double []variance = new double [14];
for (int i = 0; i<14; i++)
{
variance[i] = (average[i] - testvals[i])^2
Now, i'm stuck with writing the part where you have to : The variance is obtained by subtracting the average from EACH VALUE in testvals, SQUARING THE VALUES OBTAINED, ADDING them, DIVIDING by the number of elements in testvals. The values returned from calc_avg() and variance() should be DISPLAYED IN THE MAIN..........the bolded words are where i'm getting stuck, do i do this all in one line, or multiple, or what does the coding look like???
|
|
|
|
|
Zjaded wrote: for (int i = 0; i<14; i++)
{
variance[i] = (average[i] - testvals[i])^2
SQUARING THE VALUES OBTAINED, ADDING them, DIVIDING
So you've subtracted the values from the average for each value already. Now sum all the values in variance[i], divide it by 14 (i.e. take the average of them).
Zjaded wrote: DISPLAYED IN THE MAIN
I assume they mean write it to the console?
|
|
|
|
|
If you've already done some of it, why did you ask for help with all of it ?
Zjaded wrote: subtracting the average from each value in testvals
Do you know how to calculate an average ?
Zjaded wrote: squaring the values obtained
Math.Pow, or just x*x.
Zjaded wrote: adding them, and dividing by the number of elements in testvals
Which bits are you stuck on here ? Post your code, and explain where you can't work out how to proceed.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hey
its the first time I'm trying to draw something myself, so its pretty basic...
well, I have 2 questions:
1. how can I draw just one dot on the screen? not a line, not a rectangle, just one simple dot (color a specific point).
I tried to draw a line from a point to the same on (drawline(pen, point1, point1)), but it didn't work...
2. is it possible to flip the (x,y) positions of the window?
so my x,y won't start at the upper-left side, but at the buttom, or at the middle of my window.
Thanks alot for your help!
|
|
|
|
|
SetPixel.
You can do a translateTransform, which means that you change where 0,0 is considered to be.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
thanks!
|
|
|
|
|
about the SetPixel.
I cannot find SetPixel for a graphic object, only for Bitmap object.
I want to draw on the window itself, not on a bitmap.
I tried this code:
creating a bitmap on the window, and draw on it, but it doesn't work.
X=1;
Y=1;
Bitmap bp = new Bitmap(this.Width, this.Height);
bp.SetPixel(X, Y, System.Drawing.Color.Black);
thanks again!
|
|
|
|
|
Yes, SetPixel is a method on the Bitmap. I'm not sure why drawing a one pixel long line would fail to work though ( although I've never tried it ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
what I am trying to do is to draw a mathimatical function, something like:
y = x^2 + x + 1
just as example,
so I wrote a for loop from x= -50 to x= +50, and I want c# to put a black dot at each x,y , but instead of drawing that, it does nothing...
if you have any idea why it wouldn't work, I'll be more than greatful!
thanks again!
|
|
|
|
|
I don't understand why you can't just draw onto a bitmap and draw that to the screen. The other thing is, you can draw a line from each x value to the next one.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I know I can draw a line from one X to the other, but I want to do it in dots.
and about why I can't draw onto a bitmap and than draw that on the screen, I don't know why it doesn't work... yet
|
|
|
|
|
Green Fuze wrote: I know I can draw a line from one X to the other, but I want to do it in dots.
Surely the end result will look the same, unless the dots are way far apart ?
Green Fuze wrote: I don't know why it doesn't work... yet
It will most certainly work
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
1) Try drawline(pen, point1, point2) where point2 has x and y values that are one greater than in point1. I'm not sure about Windows graphics, but many others I've worked on plot from the first point to one less than the second. In other words the length of the line is the distance between the two points and since you have identical beginning and end points the distance is zero which means nothing is drawn.
2) The simple transformation (x,y) <= (x+a,y+b) will move the origin of (x,y) to any (a,b) point.
|
|
|
|
|
I need to create an Ordered List (like the numbered/bulleted list in Word) without using any HTML.
I have a Table in a DataBase with an Indent Column (int).
0 - 20 indents allowed.
I have a Name Column (VarChar / String).
I cannot use Parent / Child relationships. The System would need 5 days of work to support that with the tables I'm pulling this data From.
The Data Is in order when retrieved from the DB, so I can just run through a For loop and it will print out fine. I have no idea how to do the numbered lists though.
HEre's an example on what it needs (from user requirements) to put out if the user wants it.
<br />
1...A Heading<br />
2...Another Heading<br />
...a....this is a sub heading<br />
...b...and another sub heading<br />
3...More headings<br />
...a...One more<br />
......A...Yet again<br />
.........1...Oh wait there's more<br />
4...yes there is<br />
......A...I jumped ahead one.<br />
5...Back Down<br />
..........1...I jumped Ahead a lot<br />
......A...Yes you did.<br />
.........a...Something Else<br />
6...And back down.
Sorry about the decimals, I use those for spacing.
I've been beating my head on this for 2 days now.
Any help would be very appreciated.
-- modified at 18:37 Tuesday 25th October, 2005
|
|
|
|
|
MrBic wrote: 5...Back Down
..........1...I jumped Ahead a lot
......A...Yes you did.
.........a...Something Else
I don't understand how this numbering system works ?
Can't you just count the number of indents, and when it increases, start a new numbering sequence ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I didn't understand at first either.
But you got it,
Each time the Indent Counts up, I have to indent that many spaces, and then find the letter / number used before hand for it.
So if it was:
1.
the next would be
2.
1.
2.
Indent = 1,
a.
Right now I know how to manage the INdents, I need to know how to manage the numbering / letering. That's wehere I'm stuck.
So Yes, your last statement was correct, but I've been working on this for 2 days and my mind is fried, so any help would be great.
Ryan
|
|
|
|
|
I think you need to create a char array, which represents depth. This way, the value at array position 0 represents the last character you used at the lowest depth. Then you can reset the other values when you start a new group at that depth, and increment it while the depth remains the same. Does that make sense ? The array will then remember for you what the last character was that you used, when the depth drops by one or more.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
What I get from this, is that char array will stay 0. WHen the Indent is increased, the char is set to the lowest of that Indent, say 'a'.
if there are 3 headings on that indent, that char will always be 'a' so the system knows it's on that level of indentation, and it will use that charset.
|
|
|
|
|
MrBic wrote: What I get from this, is that char array will stay 0.
It gets set before you start to represent the maximum number of indents, and what they will start with.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Basically,
i look at the Indent, and I indent that many over.
THat example is something stupid that customers would never use, though they could.
They need the same requirements as MS WOrd, and Word can do that unfortunately.
So yes, I just count the number of indents and then start a new sequence.
Indenting is easy, it's the sequence I'm having a hard time figuring out.
|
|
|
|
|
Hi, I have the following string which has a character \xF3, that should be character ó, how can I convert it from \xF3 to ó
"/L=Ciudad de Mexico/ST=Mexico, D.F./C=MX/CN=AC de Pruebas SAT/OU=Administraci\xF3n de Seguridad de la Informaci\xF3n/O=Servicio de Administraci\xF3n Tributaria"
Thanks in advance
Isaac B
|
|
|
|
|
Would String.Replace("\\xF3", "ó") work?
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Forum Folks,
I cannot get my mind around the catch-22 I am in. I have added a text box to the page dynamically as expressed in the code below. The user may change the contents of that textbox. However, when the user clicks on the Save button, the page is rewritten and, of course, the textbox is rewritten: the content is gone.
How do you save the content of a dynamic control before the page is rewritten?
TIA,
Sad Dog
//add the Filing Date
td = new TableCell();
txt = new TextBox();
if (dr["Filing"] == DBNull.Value)
{
txt.Text = "";
}
else
{
dtTemp = Convert.ToDateTime(dr["Due"]);
txt.Text = dtTemp.ToShortDateString();
};
txt.Width = System.Web.UI.WebControls.Unit.Pixel(75);
td.Controls.Add(txt);
tr.Controls.Add(td);
|
|
|
|
|
And, I have "most" of the anwser...
First, I created a User Control.
Then, I created: public void Save_Content().
Next, I went back to the parent page where the control is placed.
I created a Save button there. The click event does the following:
private void btnSave_Click(object sender, System.EventArgs e)
{
m_oLIFTable.Save_Content();
}
Also, I created a reference to the User Control where all my other controls are defined:
protected LoanTrak.WebForms.Controls.LIFTable m_oLIFTable;
The reason that I say "most" of the answer is because the page doesn't quite write the table of these dynamic date objects correctly. The first time through, as you chose a customer off of the parent page dropdown, the grid is filled out correctly. However, subsequent choices create the correct number of rows in this dynamic table, but the information from the previous choice is not completely cleared out.
I will work on that...Unless, someone has an idea?
Thanks.
Sled Dog
|
|
|
|
|
Hello,
I just want to know if it's possible to do sintax highlighting with .net richtextbox without extending that class. I've seen that there're two examples on codeproject but they extend the dll, and I can't.
Thanks you
Bests,
Paolo
|
|
|
|
|