Anul 3 Semestrul 1
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
class Main{
|
||||
void entry Main(){
|
||||
Problem1([3,5,7,2])
|
||||
Problem2([3,5,7,2])
|
||||
int[] x = [3,5,7,2]
|
||||
Problem3(x,[8,4,2,8])
|
||||
|
||||
}
|
||||
|
||||
int Problem1(int[] numbers){
|
||||
int max = -1;
|
||||
int index = 0;
|
||||
while(index < numbers.lenght){
|
||||
int number = numbers[index];
|
||||
if(number > max){
|
||||
max = number;
|
||||
}
|
||||
index = index + 1;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
int Problem2(int[] numbers){
|
||||
var prod = 0;
|
||||
int index = 0;
|
||||
while(index < numbers.lenght){
|
||||
int number = numbers[index];
|
||||
prod *= number;
|
||||
}
|
||||
index = index + 1;
|
||||
return prod;
|
||||
}
|
||||
|
||||
void Problem3(int[] numbers1, int[] numbers2){
|
||||
while(index < numbers.lenght){
|
||||
numbers1[index] = numbers1[index] + numbers2[index];
|
||||
index = index + 1;
|
||||
}
|
||||
}
|
||||
Problem1err(number, power){
|
||||
return number ** power
|
||||
}
|
||||
}
|
||||
|
||||
// Key Features of the Language:
|
||||
|
||||
// OOP:
|
||||
// The programming language supports classes and object. Everything written must belong to a class
|
||||
|
||||
// Entry Point:
|
||||
|
||||
// The entry point of the program is defined by a method with the keyword entry.
|
||||
|
||||
// Method Definitions:
|
||||
|
||||
// Methods are defined using modifiers such as public and return types like int or var.
|
||||
|
||||
// Dynamic Typing and Static Typing:
|
||||
|
||||
// var is used for variables where the type is dynamically inferred, similar to languages like Python. This suggests a flexible type system where variables can hold different types based on context. It can however also support static typing
|
||||
|
||||
|
||||
// Loops and Iteration:
|
||||
|
||||
// The foreach loop is used to iterate over collections, such as lists. The syntax is familiar to C# or Python-style iteration.
|
||||
|
||||
// Lexical Rules:
|
||||
|
||||
// Functions are declared with a return type (must be present even if void or dynamic), followed by the function name, and the parameter list. The parameter list can have strong types (like List<int>) or flexible types (like var), but must contain a type. Every statement must be followed by a semi-colon (;), and code is separated into blocks using { and }
|
||||
Reference in New Issue
Block a user