Chuyển đến nội dung chính

Bài đăng

Hiển thị các bài đăng có nhãn Code Snippets

ASCII Đức Phật

// _oo0oo_ // o8888888o // 88" . "88 // (| -_- |) // 0\ = /0 // ___/`---'\___ // .' \\| |// '. // / \\||| : |||// \ // / _||||| -:- |||||- \ // | | \\\ - /// | | // | \_| ''\---/'' |_/ | // \ .-\__ '-' ___/-. / // ___'. .' /--.--\ `. .'___ // ."" ' _/___.' >' "". // | | : `- \`.;`\ _ /`;.`/ - ` : | | // \ \ `_. \_ __\ /__ _/ .-` / / // =====`-.____`.___ \_____/___.-`___.-'===== // `=---=' // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Phật phù hộ, không bao giờ BUG // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Đếm số chữ số thập phân khi chia 2 số

 Link: https://www.geeksforgeeks.org/count-number-digits-decimal-dividing-number/ We are given two numbers A and B. We need to calculate the number of digits after decimal. If in case the numbers are irrational then print “INF”. Examples:   Input : x = 5, y = 3 Output : INF 5/3 = 1.666.... Input : x = 3, y = 6 Output : 1 3/6 = 0.5 The idea is simple we follow school division and keep track of remainders while dividing one by one. If remainder becomes 0, we return count of digits seen after decimal. If remainder repeats, we return INF. // C# program to count digits after dot when a // number is divided by another. using System; using System.Collections.Generic; class GFG { static int count(int x, int y) { int ans = 0; // Initialize result var m = new Dictionary<int,int>(); // calculating remainder while (x % y != 0) { x = x % y; ans++; // if this remainder appeared before then // the numb...

ListBox Multi Select

public static class ListBoxSelectedItems { private static readonly DependencyProperty SelectedItemsBehaviorProperty = DependencyProperty.RegisterAttached( "SelectedItemsBehavior" , typeof(SelectedItemsBehavior), typeof(ListBox), null); public static readonly DependencyProperty ItemsProperty = DependencyProperty.RegisterAttached( "Items" , typeof(IList), typeof(ListBoxSelectedItems), new PropertyMetadata(null, ItemsPropertyChanged)); public static void SetItems(ListBox listBox, IList list) {listBox.SetValue(ItemsProperty, list); } public static IList GetItems(ListBox listBox) { return listBox.GetValue(ItemsProperty) as IList; } private static void ItemsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) {...