Home > Net >  C # using the cycle in the file writing characters, why don't write all? (small white questions
C # using the cycle in the file writing characters, why don't write all? (small white questions

Time:11-14

Wrote a piece of code to write Numbers in the text file, and then should write 22 is, however, only wrote about 20 line stops,
Request a great god answer

This is the cycle code:
 
for (int i=0; I & lt; Sumx; I++)
{
For (int j=0; J & lt; Sumy; J++)
{
Grd1. Write (IFF [I, j]);
Grd1. Write (" ");
}
Grd1. Write (' \ n ');
}


Sumx=22
Sumy=18
This
In fact, even if changing sumx to number 22, also can only be read in 20 lines...

The complete code is this:

 
Using System;
Using System. IO;
using System.Collections.Generic;
Using System. Windows. Forms;
The namespace yantuo
{

Public partial class Form1: Form
{
Public _click ()
{
InitializeComponent ();
}

Private void button1_Click (object sender, EventArgs e)
{
Int num1=the Convert. ToInt32 (textBox2. Text);
Int num2=the Convert. ToInt32 (textBox3. Text);


Double gravity [and]=new double [num1, num2];
Double [and] FFcos=new double [num1, num2];
Double [and] FFsin=new double [num1, num2];
Double [and] FF=new double [num1, num2];
Double [and] FFh=new double [num1, num2];
Double [and] IFF=new double [num1, num2];
Double [and] IFFcos=new double [num1, num2];
Double [and] IFFsin=new double [num1, num2];
Double [and] kk=new double [num1, num2];
Double [and] uu=new double [num1, num2];
Double [and] v. v.=new double [num1, num2];
Int m=0;

String sInFile=textBox1. Text;
Using (StreamReader reader=new StreamReader (sInFile))
{
ListThe string line=reader. ReadLine ();

While (the line!=null)
{
String [] values=line. The Split (', ');

for (int i=0; I & lt; Values. Length; I++)
{
Double num=double. Parse (values [I]);
Gravity [I] m,=num;
}
M=m + 1;
The line=reader. ReadLine ();
}
}

for (int i=0; I & lt; Gravity. GetLength (0); I++)
{
For (int j=0; J & lt; Gravity. GetLength (1); J++)
{
For (int x=0; X & lt; Gravity. GetLength (0); X++)
{
For (int y=0; Y & lt; Gravity. GetLength (1); Y++)
{
FFcos [I, j]=FFcos [I, j] + gravity (x, y) * math.h Cos (2 * math.h PI * (Convert. ToDouble (I) * Convert ToDouble (x)/Convert ToDouble (num1) + the Convert. ToDouble (j) * Convert ToDouble (y)/Convert ToDouble (num2)));
FFsin [I, j]=FFsin [I, j] + gravity (x, y) * math.h Sin (2 * math.h PI * (Convert. ToDouble (I) * Convert ToDouble (x)/Convert ToDouble (num1) + the Convert. ToDouble (j) * Convert ToDouble (y)/Convert ToDouble (num2)));
FF [I, j]=math.h Pow ((math.h Pow (FFcos (I, j), 2) + math.h Pow (FFsin (I, j), 2)), 0.5);
}
}
}
}

for (int i=0; I & lt; FF. GetLength (0); I++)
{
For (int j=0; J & lt; FF. GetLength (1); J++)
{
Uu Math. [I, j)=I * PI * 2/num1;
V. v. [I, j]=j * Math PI * 2/num2;
Kk [I, j]=math.h Pow ((math.h Pow (uu (I, j), 2) + math.h Pow (vv (I, j), 2)), 0.5);//calculate the wave number k
}
}

Int dh=the Convert. ToInt32 (textBox4. Text);//set the continuation height
If (comboBox1. Text=="down")
{
Dh=- dh;
}
for (int i=0; I & lt; FF. GetLength (0); I++)
{
For (int j=0; J & lt; FF. GetLength (1); J++)
{
FFh [I, j]=Math. J Exp (- dh * kk [I, j]) * FF (I, j),//after the continuation of Fourier calculation FFh
}
}

for (int i=0; I & lt; FFh. GetLength (0); I++)
{
For (int j=0; J & lt; FFh. GetLength (1); J++)
{
For (int x=0; X & lt; FFh. GetLength (0); X++)
{
For (int y=0; Y & lt; FFh. GetLength (1); Y++)
{
IFFcos [I, j]=IFFcos [I, j] + (FFh (x, y) * math.h Cos (2 * math.h PI * (Convert. ToDouble (I) * Convert ToDouble (x)/Convert ToDouble (num1) + the Convert. ToDouble (j) * Convert ToDouble (y)/Convert ToDouble (num2)))/(the Convert. ToDouble (num1) * Convert ToDouble (num2)));
IFFsin [I, j]=IFFsin [I, j] + (FFh (x, y) * math.h Sin (2 * math.h PI * (Convert. ToDouble (I) * Convert ToDouble (x)/Convert ToDouble (num1) + the Convert. ToDouble (j) * Convert ToDouble (y)/Convert ToDouble (num2)))/(the Convert. ToDouble (num1) * Convert ToDouble (num2)));
IFF [I, j]=math.h Pow ((math.h Pow (IFFcos (I, j), 2) + math.h Pow (IFFsin (I, j), 2)), 0.5);
}
}
}
}

FileStream aFile=new FileStream (textBox5. Text, FileMode. OpenOrCreate);
StreamWriter ver=new StreamWriter (aFile);//in the export data

for (int i=0; I & lt; Gravity. GetLength (0); I++)
{
For (int j=0; J & lt; Gravity. GetLength (1); J++)
{
If (gravity [I, j]!=0)
{
Ver. Write (IFF [I, j]);
Ver. Write (', ');
}
}
If (gravity [I, 1)!=0 & amp; & Gravity [I, 2)!=0 & amp; & Gravity [I, 3].=0)
Ver. Write (' \ n ');
}
Ver. Close ();
TextBox6. Text="Complete";
FileStream cFile=new FileStream (textBox7. Text, FileMode. OpenOrCreate);

StreamWriter GRD=new StreamWriter (cFile);//in the export data
//write the first line
String f="ID, type, value, ORIG_FID point_x, point_y";
GRD. Write (f);
GRD. Write (' \ n ');
Int k=1;
for (int i=0; I & lt; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  •  Tags:  
  • C#
  • Related