Guest User

Untitled

a guest
May 21st, 2017
67
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. public struct Book
  4. {
  5.     public string name;
  6.     public string field;
  7.     public int year;
  8. }
  9.                
  10. public class Program
  11. {
  12.        
  13.     public static void Main()
  14.     {
  15.    
  16.         Book[] library = new Book[6];
  17.        
  18.         //....some other code....
  19.        
  20.        
  21.         Console.WriteLine("Hello World!");
  22.     }
  23.    
  24.     public int TotalCount(Book[] books, int n, string field)
  25.     {
  26.         int count = 0;
  27.        
  28.         for(int i =0; i<n; i++)
  29.             if(books[i].field==field)
  30.                 count++;
  31.            
  32.         return count;
  33.     }
  34.    
  35.     public Book FindOldest(Book[] books, int n)
  36.     {
  37.         Book oldest = books[0];
  38.        
  39.         for(int i =1; i<n; i++)
  40.             if(books[i].year<oldest.year)
  41.                 oldest = books[i];
  42.            
  43.         return oldest;
  44.     }
  45. }
RAW Paste Data