All generations.

generate functionWed, 16 Nov 2022

store a value on days of the different months in a calendar

int[] jan = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31} int[] feb = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29} int[] mar = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31} int[] apr = new int[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15

generate functionWed, 23 Nov 2022

array of the days of a year

using System; namespace ConsoleApp3 { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); } public static string[] days() { string[] days = new string[365]; for (int i = 0; i < 365; i++) { days[i] = "Hello"; } return days; } } }

generate functionWed, 16 Nov 2022

create a data stracture of a calendar

public static int BinarySearch(int[] array, int target) { int left = 0; int right = array.Length - 1; while (left <= right) { int middle = (left + right) / 2; if (array[middle] == target) return middle; else if (target < array[middle]) right = middle - 1; else left = middle + 1; } return -1; }

translateSat, 12 Nov 2022

find the second largest value from an array

public class Solution { public int FindSecondLargest(int[] nums) { int maxValue = int.MinValue; int secondMaxValue = int.MinValue; foreach (int num in nums) { if (num > maxValue) { secondMaxValue = maxValue; maxValue = num; } else if (num > secondMaxValue && num < maxValue) { secondMaxValue = num; } } return secondMaxValue; } }

generate functionWed, 16 Nov 2022

nxn matrix

public static int[,] GenerateMatrix(int n) { int[,] matrix = new int[n, n]; for (int row = 0; row < n; row++) { for (int col = 0; col < n; col++) { matrix[row, col] = row + col; } } return matrix; } public static string PrintMatrix(int[,] matrix) { StringBuilder output = new StringBuilder(); int n = matrix.GetLength(0); for (int row = 0; row < n; row++) { for (int col = 0; col < n; col++) { output.Append(matrix[row, col] + " "); } output.AppendLine(); } return output.ToString().TrimEnd(); }

generate functionWed, 23 Nov 2022

array of calendar days

public static class Calendar { public static IEnumerable<DateTime> Days(DateTime from, DateTime thru) { for(var day = from.Date; day.Date.CompareTo(thru.Date) <= 0; day = day.AddDays(1)) yield return day; } }

generate functionWed, 23 Nov 2022

array of days of the months

static int[] MonthDays = new int[12] { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; static void Main(string[] args) { Console.WriteLine(GetDaysOfMonth(3)); } static int GetDaysOfMonth(int Month) { return MonthDays[Month]; }

generate functionWed, 23 Nov 2022

2 dimensional array

public class Solution { public int[][] GenerateMatrix(int n) { int[][] matrix = new int[n][]; for(int i = 0; i < n; i++){ matrix[i] = new int[n]; } int i = 1; int rowStart = 0; int rowEnd = n-1; int colStart = 0; int colEnd = n-1; while(rowStart <= rowEnd && colStart <= colEnd){ for(int j = colStart; j <= colEnd; j++){ matrix[rowStart][j] = i++; } rowStart++; for(int j = rowStart; j <= rowEnd; j++){ matrix[j][colEnd] = i++; } colEnd--; if(rowStart <= rowEnd){ for(int j = colEnd; j >= colStart; j--){ matrix[rowEnd][j] = i++;

generate functionWed, 23 Nov 2022

array of months

public string[] months = { "January","February","March","April","May","June","July","August","September","October","November","December"};

generate functionWed, 16 Nov 2022

a table wich contains montsh repetedly and the days store a value

Dictionary<string, int> months = new Dictionary<string, int>(); months.Add("Jan", 31); months.Add("Feb", 28); months.Add("Mar", 31); months.Add("Apr", 30); months.Add("May", 31); months.Add("Jun", 30); months.Add("Jul", 31); months.Add("Aug", 31); months.Add("Sep", 30); months.Add("Oct", 31); months.Add("Nov", 30); months.Add("Dec", 31);

generate functionWed, 16 Nov 2022

create a list of 12 month list and for every day a dictionary

public static List<List<Dictionary<string, object>>> GetMonths() { List<List<Dictionary<string, object>>> months = new List<List<Dictionary<string, object>>>(); for (int week = 1; week <= 12; week++) { List<Dictionary<string, object>> days = new List<Dictionary<string, object>>(); for (int day = 1; day <= 31; day++) { Dictionary<string, object> date = new Dictionary<string, object>(); date.Add("month", week); date.Add("day", day); date.Add("date", week + "/" + day); days.Add(date); } months.Add(days); } return months; }

generate functionWed, 16 Nov 2022

create a calendar in which every day can hold a value

public class Day { public string Value { get; set; } public Day(string value) { Value = value; } } public class Calendar { private List<Day> days; public Calendar(List<Day> days) { this.days = days; } public void SetValueAt(int index, string value) { this.days[index].Value = value; } public string GetValueAt(int index) { return this.days[index].Value; } public bool IsDayWithValue(string value) { return this.days.Any(day => day.Value == value); } public int GetIndexOfDayWithValue(string value) { for (int i = 0; i < this.days.Count; i++) { if (this.days[i].Value == value) { return i; } } return -1;

generate functionWed, 16 Nov 2022

list of months

public static IEnumerable<string> Months() { return new List<string> { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; }

generate functionWed, 16 Nov 2022

create a calendar which holds the months, the day of the months can hold an integer value i have to count the number of ints per day

public static int[] DaysPerMonth = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; public static int[] Counts = new int[31]; public class Triplet { public int Month { get; private set; } public int Day { get; private set; } public int Value { get; private set; } public Triplet(int month, int day, int value) { Month = month; Day = day; Value = value; } } public static void Main(string[] args) { string line; List<Triplet> triples = new List<Triplet>(); while ((line = Console.ReadLine()) != null) { string[] parts = line.Split(' '); triples.Add(new Triplet( Int32.Parse(parts[0]), Int32.Parse(parts[1]), Int32.Parse(parts[2]))); }

Questions about programming?Chat with your personal AI assistant