Skip to content

Instantly share code, notes, and snippets.

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Stream;
/*
* Write a program to read a text file "Input.txt" holding a sequence of integer numbers,
* each at a separate line. Print the sum of the numbers at the console.
* Ensure you close correctly the file in case of exception or in case of normal execution.
import java.util.Scanner;
public class Class_01_RectangleArea {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
System.out.print("a = ");
int a = Integer.parseInt(console.next());
System.out.print("b = ");
int b = Integer.parseInt(console.next());
@nstanevski
nstanevski / 07_VladkosNotebook.cs
Created May 19, 2015 15:43
Advanced C# Exam Problems Practice
using System;
using System.Collections.Generic;
class VladkosNotebook
{
static void Main()
{
SortedDictionary<string, Dictionary<string, dynamic>> notebook
= new SortedDictionary<string, Dictionary<string, dynamic>>();
@nstanevski
nstanevski / 01_SeriesOfLetters.cs
Last active August 29, 2015 14:21
Homework#5 - Regular Expressions
using System;
using System.Text.RegularExpressions;
/*
* Write a program that reads a string from the console and replaces all series
* of consecutive identical letters with a single one.
*/
class SeriesOfLetters
{
using System;
// Write a program that reads a string from the console, reverses it
// and prints the result back at the console.
class ReverseString
{
static void Main(string[] args)
{
char[] charArr = Console.ReadLine().ToCharArray();
@nstanevski
nstanevski / 01_FillTheMatrix.cs
Last active August 29, 2015 14:20
Homework 02 - Multidimensional Arrays, Sets, Dictionaries
using System;
/*
* Write two programs that fill and print a matrix of size N x N.
* Filling a matrix in the regular pattern (top to bottom and left to right) is boring.
* Fill the matrix as described in both patterns below
* Example 1:
* 1 6 11 16 21
* 2 7 12 17 22
* 3 8 13 18 23
@nstanevski
nstanevski / 01_BiggerNumber.cs
Last active August 29, 2015 14:20
Homework 02 - Methods
using System;
/*
* Write a method GetMax() with two parameters that returns the larger of two integers.
* Write a program that reads 2 integers from the console and prints the largest of them
* using the method GetMax().
*/
class BiggerNumber
@nstanevski
nstanevski / 01_SortArrayOfNumbers.cs
Last active August 29, 2015 14:20
Homework#1 - Arrays, Lists, Stacks, Ques
using System;
using System.Linq;
/*
*Write a program to sort an array of numbers and then print them back on the console.
*The numbers should be entered from the console on a single line, separated by a space.
*/
class SortArrayOfNumbers
{