Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module com.proj.MonPremProg;
- import tango.io.Stdout;
- import tango.io.Console;
- import tango.util.Convert;
- uint sommeT(uint[] tableau, uint a)
- {
- uint somme = 0;
- foreach(compteur,element; tableau)
- {
- somme += element;
- Stdout.formatln("{}", compteur);
- }
- return somme;
- }*/
- class A
- {
- public this(){}
- protected int a;
- }
- class B : A
- {
- public this(){a = 3;}
- }
- class B
- {
- }
- int main()
- {
- uint d = 40, b = 80;
- Stdout.formatln("{} + {} = {}", a, b, a+b);
- Stdout.formatln("{} - {} = {}", a, b, a-b);
- Stdout.formatln("{} x {} = {}", a, b, a*b);
- Stdout.formatln("{} / {} = {}", 1, 3, 1/3);
- Stdout.formatln("{} % {} = {}", a, b, a%b);
- Stdout("{} % {} = {}", a, b, a%b);
- Stdout("{} % {} = {}", a, b, a%b).newline;
- Stdout.formatln("{}", a++);
- Stdout.formatln("{}", a);
- a = 40;
- Stdout.formatln("{}", a--);
- a = 40;
- Stdout.formatln("{}", --a);
- Stdout.formatln("{}+{}", 1, 2);
- if(a == 40)
- Stdout.formatln("a = {}", a);
- else
- Stdout("False");
- char[] c;
- c = "lol"c ~ "lol"w; // error, incompatibles types for char and wchar
- //Associative Arrays
- int[char[]] a;
- a["pommes"] = 42;// have 42 apple
- a["fraises"] = 21;
- a["cerises"] = 3;
- a["framboises"] = 256000;
- Stdout.formatln("{}", a);
- Stdout.formatln("{}", a.rehash);
- uint age = 2;//to!(uint)(Cin.get);
- Stdout.formatln("Age : {}, Adresse Age : {}", age, &age);
- uint* p_age = &age;
- uint[];
- Stdout.formatln("{}", sommeT(tableau,tableau.length));
- uint a = to!(uint)(Cin.get());
- uint[3][4] matrice;
- foreach(compteur, element; matrice)
- {
- element[0..2] = 1 + compteur;
- Stdout.formatln("{}", element);
- }
- char* b = null;
- b = 'b';
- Stdout.formatln("{}", b);
- const uint[] a = [1:2];
- Stdout.formatln("{}", a[3]);
- Stdout.formatln("{}", a);
- uint[] b = a.sort;
- b[0] = 2;
- Stdout.formatln("{}", b).formatln("{}", a);
- a[0] = 4;
- Stdout.formatln("{}", b);
- for(uint i = 0; i < 10; ++i)
- Stdout(i).newline;
- uint[4][4] a;
- foreach(element;a)
- a[0..$][0..$] = 54;
- Stdout.formatln("{}", a);
- B o;
- if(cast(B) o)
- Stdout("o is an instance of B").newline;
- else
- Stdout("o isn't an instance of B").newline;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement