Skip to content

Instantly share code, notes, and snippets.

@WildGenie
Last active March 10, 2016 15:52
Show Gist options
  • Save WildGenie/3132d0415891e11739a7 to your computer and use it in GitHub Desktop.
Save WildGenie/3132d0415891e11739a7 to your computer and use it in GitHub Desktop.
namespace mat_islem
{
public static class matematik
{
public static int cift(int a, int b)
{
if (a < b)
{
int sonuc1 = 0;
for (int i = a; i <= b; i++)
{
if (i % 2 == 0)
{
sonuc1 = sonuc1 + i;
}
}
return sonuc1;
}
else if (b < a)
{
int sonuc2 = 0;
int x = 0;
for (int i = b; i <= a; i++)
{
if (i % 3 == 0)
{
sonuc2 = sonuc2 + i;
x = x + 1;
}
}
int sonuc3 = sonuc2 / x;
return sonuc3;
}
else
{
return a; //yada 0 ikisininde eşit olma durumu
}
}
}
}
using System;
using System.Windows.Forms;
using mat_islem;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
label1.Text = matematik.cift(Convert.ToInt32(textBox1.Text), Convert.ToInt32(textBox2.Text)).ToString();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment