Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 2.34 KB | None | 0 0
  1. module com.proj.MonPremProg;
  2.  
  3.  
  4. import tango.io.Stdout;
  5. import tango.io.Console;
  6. import tango.util.Convert;
  7.  
  8. uint sommeT(uint[] tableau, uint a)
  9. {
  10.        uint somme = 0;
  11.        foreach(compteur,element; tableau)
  12.        {
  13.            somme += element;
  14.            Stdout.formatln("{}", compteur);
  15.            
  16.        }
  17.        return somme;
  18. }*/
  19.  
  20. class A
  21. {
  22.     public this(){}
  23.     protected int a;
  24. }
  25.  
  26. class B : A
  27. {
  28.     public this(){a = 3;}
  29. }
  30. class B
  31. {
  32.    
  33. }
  34. int main()
  35. {
  36.    
  37.  
  38.     uint d = 40, b = 80;
  39.     Stdout.formatln("{} + {} = {}", a, b, a+b);
  40.     Stdout.formatln("{} - {} = {}", a, b, a-b);
  41.     Stdout.formatln("{} x {} = {}", a, b, a*b);
  42.     Stdout.formatln("{} / {} = {}", 1, 3, 1/3);        
  43.  
  44.                                                      
  45.     Stdout.formatln("{} % {} = {}", a, b, a%b);
  46.     Stdout("{} % {} = {}", a, b, a%b);
  47.     Stdout("{} % {} = {}", a, b, a%b).newline;
  48.     Stdout.formatln("{}", a++);
  49.    
  50.     Stdout.formatln("{}", a);
  51.     a = 40;
  52.     Stdout.formatln("{}", a--);
  53.     a = 40;
  54.     Stdout.formatln("{}", --a);
  55.     Stdout.formatln("{}+{}", 1, 2);
  56.     if(a == 40)
  57.         Stdout.formatln("a = {}", a);
  58.     else
  59.         Stdout("False");
  60.    
  61.     char[] c;
  62.     c = "lol"c ~ "lol"w; // error, incompatibles types for char and wchar
  63.    
  64.     //Associative Arrays
  65.     int[char[]] a;
  66.     a["pommes"] = 42;// have 42 apple
  67.     a["fraises"] = 21;
  68.     a["cerises"] = 3;
  69.     a["framboises"] = 256000;
  70.    
  71.     Stdout.formatln("{}", a);
  72.     Stdout.formatln("{}", a.rehash);
  73.    
  74.    uint age = 2;//to!(uint)(Cin.get);
  75.     Stdout.formatln("Age : {}, Adresse Age : {}", age, &age);
  76.     uint* p_age = &age;
  77.    
  78.    
  79.     uint[];
  80.     Stdout.formatln("{}", sommeT(tableau,tableau.length));
  81.     uint a = to!(uint)(Cin.get());
  82.     uint[3][4] matrice;
  83.     foreach(compteur, element; matrice)
  84.     {
  85.         element[0..2] = 1 + compteur;
  86.         Stdout.formatln("{}", element);
  87.     }
  88.     char* b = null;
  89.     b = 'b';
  90.     Stdout.formatln("{}", b);
  91.     const uint[] a = [1:2];
  92.    
  93.     Stdout.formatln("{}", a[3]);
  94.    
  95.     Stdout.formatln("{}", a);
  96.     uint[] b = a.sort;
  97.     b[0] = 2;
  98.    
  99.     Stdout.formatln("{}", b).formatln("{}", a);
  100.     a[0] = 4;
  101.     Stdout.formatln("{}", b);
  102.     for(uint i = 0; i < 10; ++i)
  103.         Stdout(i).newline;
  104.     uint[4][4] a;
  105.     foreach(element;a)
  106.          a[0..$][0..$] = 54;
  107.     Stdout.formatln("{}", a);
  108.     B o;
  109.     if(cast(B) o)
  110.         Stdout("o is an instance of B").newline;
  111.     else
  112.         Stdout("o isn't an instance of B").newline;
  113.    
  114.     return 0;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement