我不知道Program WriteFile;
Uses Crt;
Var Dur,ts,tv,n,vers,i : integer;
X,FileName : String[12];
f : file of integer;
begin
ClrScr;
Write('Variant=');
Readln(vers);
Write('Number of works=');
Readln(n);
Str(vers,X);
FileName:='Shed'+X+'.tab';
Assign(f,FileName);
Rewrite(f);
For i:=1 to n do
begin Writeln(i,'-th work:');
Write('time of beginning=');
Readln(ts);
Write('during=');
Readln(Dur);
tv:=ts+Dur;
Write(f,ts,Dur,tv)
end;
Close(f)
end.
,这就是我要问的原因。
也许它创建了文件并写了一些东西
有一个Pascal代码
req.body
答案 0 :(得分:0)
我认为会是这样的:
static void Main(string[] args)
{
Console.Clear(); //unnecessary
Console.Write("Variant=");
int vers = Int32.Parse(Console.ReadLine());
Console.Write("Number of works=");
int n = Int32.Parse(Console.ReadLine());
string X = vers.ToString();
string FileName = "Shed" + X + ".tab";
//or string FileName = "Shed" + vers.ToString() + ".tab"; //without unnecessary X variable
System.IO.File.WriteAllText(FileName, string.Empty); //clear file
System.IO.StreamWriter file = new System.IO.StreamWriter(FileName);
int ts;
int dur;
int tv;
for (int i = 0; i < n; i++)
{
Console.WriteLine(i.ToString() + "-th work:");
Console.Write("time of beginning=");
ts = Int32.Parse(Console.ReadLine());
Console.Write("during=");
dur = Int32.Parse(Console.ReadLine());
tv = ts + dur;
file.WriteLine(ts.ToString() + "\t" + dur.ToString() + "\t" + tv.ToString());
}
file.Close();
}