Monthly Archives: July 2017
C# Windows Application Form
code:
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace PersonalInformationApp { public partial class MainUI : Form { public MainUI() { InitializeComponent(); } private string firstName, lastName, fathersName, mothersName, address; private void AddressButton_click(object sender, EventArgs e) { MessageBox.Show(address); } private void parentsButton_click(object sender, EventArgs e) { fathersNameTextBox.Text = fathersName; mothersNameTextBox.Text = mothersName; MessageBox.Show("Fathers Name: " + fathersName + "\n" + "Mothers Name: " + mothersName); } private void saveButton_Click(object sender, EventArgs e) { firstName = firstNameTextBox.Text; lastName = lastNameTextBox.Text; fathersName = fathersNameTextBox.Text; mothersName = mothersNameTextBox.Text; address = addressTextBox.Text; firstNameTextBox.Text = ""; lastNameTextBox.Clear(); fathersNameTextBox.Text=string.Empty; mothersNameTextBox.Text = string.Empty; addressTextBox.Text = null; } private void showAllInformationButton_Click(object sender, EventArgs e) { firstNameTextBox.Text = firstName; lastNameTextBox.Text = lastName; fathersNameTextBox.Text = fathersName; mothersNameTextBox.Text = mothersName; addressTextBox.Text = address; } private void nameButton_Click(object sender, EventArgs e) { MessageBox.Show(firstName+" "+lastName); } } } |
code:
1 2 3 4 5 6 7 8 9 10 11 |
LinearSearch(Array A, value) { BEGIN for i=0 to A.length-1 if(A[i]==value) then return i; end if end for return -1 //if desired value not found return -1 END } |
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 32 33 |
#include<bits/stdc++.h> using namespace std; int LinearSearch(int *A,int n,int x) { int i; for(i=0; i<n; i++) { if(A[i]==x) return i; } return -1; } int main() { int x,i,n; int A[5] = {3,5,9,8,16}; printf("Put value to search from an array: "); scanf("%d",&x); int output=LinearSearch(A,5,x); if(output==-1) { printf("%d is not found",x); } else { printf("%d is in index %d\n",x,output); } return 0; } |
Posted in Uncategorized
OOP Topics Need To Cover
Posted in OO Analysis and Design, OOP
OOP Topics Need To Cover
Posted in OO Analysis and Design, OOP
OOP Topics Need To Cover
Posted in OO Analysis and Design, OOP
OOP in C#
Calculator.cs
1 2 3 4 5 6 7 8 9 10 11 |
namespace ConsoleApp6.Math { public class Calculator { public int Add(int a,int b) { return a + b; } } } |
Program.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
using ConsoleApp6.Math; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp6 { class Program { static void Main(string[] args) { Person john = new Person(); john.FirstName = "John"; john.LastName = "Smith"; john.Introduce(); Calculator calculator = new Calculator(); var result = calculator.Add(1, 2); System.Console.WriteLine(result); } } } |
Person.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
using System; namespace ConsoleApp6 { public class Person { public string FirstName; public string LastName; public void Introduce() { Console.WriteLine("My name is:"+FirstName+" "+LastName); } } } |
C# Book Tips
Bellman Ford
It works on negative cycle.
Implemented Code:
Time Complexity:
O([E].[V])
Reference:
http://cyberlingo.blogspot.com/2015/07/bellman-ford-algorithm.html
Posted in Algo Unsolved, Bellman Ford, Single Source Shortest Path
Tagged not greedy