小编Mil*_*imz的帖子

查找文本文件中最长的单词

我试图制作一个简单的脚本,使用bash在文本文件中查找最大的单词及其数量/长度.我知道当我使用awk它简单直接但我想尝试使用这种方法... a=wmememememe我想我知道如果我想找到长度我可以使用echo {#a}它的话我会echo ${a}.但是我想在下面应用它

for i in `cat so.txt` do
Run Code Online (Sandbox Code Playgroud)

so.txt包含单词,我希望它有意义.

unix linux bash

15
推荐指数
4
解决办法
1万
查看次数

用Delphi中的listbox替换stringgrid

我试图分别替换stringgrid1stringgrid2使用listbox1listbox2.他们以任何方式我能做到吗?如果listbox做不到可能有人建议我应该使用什么而不是stringgrid显示信息?我是德尔福的新手.

这是我的代码:

procedure TForm2.FormCreate(Sender: TObject);
var i:integer;
begin
stringgrid1.ColWidths[0]:=20;
stringgrid2.ColWidths[0]:=20;
for i:=1 to 50 do begin
    stringgrid1.Cells[0,i]:=inttostr(i-1);
    stringgrid2.Cells[0,i]:=inttostr(i-1);
    stringgrid2.Cells[1,i]:='0';
end;
  stringgrid2.Cells[1,0]:='name';
  stringgrid1.Cells[1,0]:='extension';
  stringgrid1.Cells[2,0]:='format';
  stringgrid1.Cells[3,0]:='size';
  stringgrid1.Cells[4,0]:='date';
  stringgrid1.Cells[5,0]:='addres';
end;

procedure TForm2.StringGrid2DblClick(Sender: TObject);
begin
if (stringgrid2.Cells[1,stringgrid2.Row]<>'1024') and (stringgrid2.Cells[1,stringgrid2.Row]<>'0') then
  stringgrid1.Row:=strtoint(stringgrid2.Cells[1,stringgrid2.Row]);

end;
Run Code Online (Sandbox Code Playgroud)

结束.

Procedure HD;
var i:integer;
begin
   for i:=0 to 50 do begin
     form2.StringGrid1.Cells[1,i+1]:=TABLE[i].name;
     form2.StringGrid1.Cells[2,i+1]:=TABLE[i].format;
     if TABLE[i].tip then
           form2.StringGrid1.Cells[3,i+1]:='folder'
     else
           form2.StringGrid1.Cells[3,i+1]:='file';
     form2.StringGrid1.Cells[4,i+1]:=inttostr(TABLE[i].nach);
     form2.StringGrid1.Cells[5,i+1]:=inttostr(TABLE[i].razmer);
     form2.StringGrid2.Cells[1,i+1]:=inttostr(fat[i]);;
   end;
end;
Run Code Online (Sandbox Code Playgroud)

delphi

6
推荐指数
1
解决办法
2224
查看次数

列表索引超出范围(0)

我在Delphi中发布了一个关于在方法声明中修复错误的问题,但在修复它之后,在编译时弹出了另一个错误,并且它说项目project1.exe引发异常类EStringListError,消息'list index out of bounds(0) '.当我按下继续它不工作,但当我按下它在代码上闪烁 neraz:=true; 这是我的代码如下

Procedure Reload;
var
    i:integer;
begin
form1.ListBox1.Clear;
form1.ListBox2.Clear;
if neraz then
HD;
neraz:=true;//..................here
form1.Label3.Caption:='free: '+inttostr(vs*32)+' byte'+#10#13+'cluster size = 32 bytes';
  i:=TABLE[nk1].nach;
   KolP1:=0; KolP2:=0;
   while (FAT[i]<>1024)  do begin
      if TABLE[fat[i]].tip then begin
          form1.ListBox1.Items.Add('dir>'+TABLE[fat[i]].name);
          inc(kolP1);
      end
      else
          if TABLE[fat[i]].format='txt' then
                form1.ListBox1.Items.Add('f_text> '+TABLE[fat[i]].name+'.'+TABLE[fat[i]].format)
          else
                form1.ListBox1.Items.Add('f_bin> '+TABLE[fat[i]].name+'.'+TABLE[fat[i]].format);
      if (fat[i]<>0) then
      i:=fat[i];
   end;
   i:=TABLE[nk2].nach;
   while (FAT[i]<>1024)  do begin
      if TABLE[FAT[i]].tip then begin
          form1.ListBox2.Items.Add('dir>'+TABLE[fat[i]].name);
          inc(kolP2)
      end
      else
          if TABLE[fat[i]].format='txt' then
                form1.ListBox2.Items.Add('f_text> '+TABLE[fat[i]].name+'.'+TABLE[fat[i]].format)
          else
                form1.ListBox2.Items.Add('f_bin> '+TABLE[fat[i]].name+'.'+TABLE[fat[i]].format);
      if (fat[i]<>0) then
      i:=fat[i]; …
Run Code Online (Sandbox Code Playgroud)

delphi

2
推荐指数
1
解决办法
1万
查看次数

在C#中过滤文本文件

我如何只打开扩展名为.txt的文件,如果文件不是.txt文件,我希望我的程序弹出错误信息我想要一个可以在下面修改此代码的代码

private void button1_Click(object sender, EventArgs e)
{
   OpenFileDialog of = new OpenFileDialog();
   of.ShowDialog();
   textBox1.Text = of.FileName;
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮我们说我想把这个循环

if fileextension is .txt then 
OpenFileDialog of = new OpenFileDialog();
            of.ShowDialog();
            textBox1.Text = of.FileName;
else show error message(like can not open this file)
Run Code Online (Sandbox Code Playgroud)

c#

2
推荐指数
1
解决办法
3863
查看次数

了解如何使用类

我试图了解如何在C#中使用或访问多个类,有人可以向我解释这段代码的作用吗?

public class Mammal : Animal
{   
    public Mammal(String name) : base(name) { }

    public override void Eat(Food food)
    {
        Console.WriteLine("Mammal \"" + Name + "\" eats " + food.Name);
    }
}
Run Code Online (Sandbox Code Playgroud)

目的是public override void Eat(Food food)什么?我的意思是它做了什么?

namespace ConsoleApplication1
{
    public class Food
    {
        private String name;

        Food(String name)
        {
            this.name = name;
        }

        public String Name
        {
            get 
            {
                return name;
            }
            set
            {
                name = value;
            }
        }   
    }

    public class Animal
    {
        private String name …
Run Code Online (Sandbox Code Playgroud)

c# class

2
推荐指数
2
解决办法
605
查看次数

如何使用类

我一直在学习c ++中的课程,我从一本古老的俄语书中得到了一些关于书类的代码,我尝试修改它并运行它不工作可能有些帮助我理解为什么authour使用了这个代码(什么是strdup)做?)

Author = strdup(autho);

在构造函数内部,这行代码错误

Book s("edgar", "science", "chemistry for dummies", "502","12.11.13","1.12.96");
Run Code Online (Sandbox Code Playgroud)

有简单直接解释的人吗?

主要代码如下

using namespace std;

class Book{

    char * Author;
    char * Type;
    char * Title;
    int * Pages;
    unsigned int * Yearpublished;
    unsigned int  * Publishing;

    Book(char * autho, char * type, char * title,   int * pages, unsigned int * yearpublished, unsigned int  * publishing ){

        Author = strdup(autho);
        Type = strdup(type);
        Title = strdup(title);
        Pages = pages;
        Yearpublished = yearpublished;
        Publishing = publishing;

    } …
Run Code Online (Sandbox Code Playgroud)

c++ class

0
推荐指数
1
解决办法
155
查看次数

标签 统计

c# ×2

class ×2

delphi ×2

bash ×1

c++ ×1

linux ×1

unix ×1