Private Sub Pathget_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Pathget.DragDrop Dim fileName() As String = e.Data.GetData(DataFormats.FileDrop, False) Dim i As Integer Dim fpath As String Dim buff(9999) As String Dim datafile As String Dim a As Integer = 0 Dim d As Integer Dim ddd As String
FileOpen(1, fpath, OpenMode.Input) pathget.Text = "asshole" While Not EOF(1) d = 0 While d < 20 buff(a) = buff(a) & LineInput(1) & Chr(13) & Chr(10) d = d + 1 ddd = ddd & d & " " & a & "|" pathget.Text = ddd End While a = a + 1 pathget.Text = "asshole3" End While
>>426 interface FunctorInt{ public abstract int call(int n); }
class FctrSqr implements FunctorInt { public int call(int n){return n*n;} }
public class Main { static int recursiveSigma(int nextLevel, FunctorInt fctr, int k){ if( nextLevel == 0 ){ return fctr.call(k); }else{ int sum = 0; for(int i = 0; i <= k; ++i){ sum += recursiveSigma(nextLevel-1, fctr, i); } return sum; } }
public static void main(String[] args){ System.out.println("ans = " + recursiveSigma(3, new FctrSqr(), 100)); } }
どうせならクラスにしちまおう interface FunctorInt{ public abstract int call(int n); }
class FctrSqrInt implements FunctorInt { public int call(int n){return n*n;} }
class RecursiveSigma{ FunctorInt fctr; public RecursiveSigma(FunctorInt fctr){ this.fctr = fctr;} public int calc(int nestLevel, int k){ if( nestLevel == 0 ){ return fctr.call(k); }else{ int sum = 0; for(int i = 0; i <= k; ++i){ sum += calc(nestLevel-1, i); } return sum; } } }
public class Main { public static void main(String[] args){ RecursiveSigma rsigma = new RecursiveSigma(new FctrSqrInt()); System.out.println("ans = " + rsigma.calc(3, 100)); } }