close

homework2
  private void button1_Click(object sender, System.EventArgs e)
  {
   textBox3.Text=GCD(System.Convert.ToInt32(textBox1.Text),System.Convert.ToInt32(textBox2.Text)).ToString();
  }
  private static int GCD(int m,int n)
  {
   if((m%n)==0)
    return n;
   else
    return GCD (n,m%n);


homework3
  public static void Main()
  {
   int x=0;
   int y=0;
   int z=0;
   for (int i=1;i<=100;i++)
   {
    if (i%6==0) continue;
    else if(i%2==0)
     x=x+i;
    else if (i%3==0)
     y=y+i;
    z=x+y;
   }
   Console.WriteLine(z);
   Console.ReadLine();

  
  }


arrow
arrow
    全站熱搜

    fatfather 發表在 痞客邦 留言(0) 人氣()