วันเสาร์ที่ 29 มกราคม พ.ศ. 2554

แลปเสริมประสบการณ์

ลองทำเองดูก่อนนะ แล้วค่อยถามมา ถ้าทำไม่ได้ยังไง ไปโฑสไว้ในเฟส จะสอนให้ทีละคน เพราะแลปนี้ มัน ประมาณข้อสอบอะ ไม่ต้องการสำร้าย พวกคุณ  เพราะฉนะั้น ไม่เข้าใจ โพสไว้ในเฟสผม แดี๋ยวไปตอบให้นะ ครับ ไไม่อยากเอาเฉลย ลงอะ เพราะเดี่๋ยวไม่ได้คิดกัน

วันอังคารที่ 25 มกราคม พ.ศ. 2554

เมธอด 2 และไฟล์ข้อมูล ฉบับสมบูรณ์

ข้อที่ 1
using System;
class MainClass
{
    static void add_bonus(){
        
    }
    public static void Main(string[] args)
    {
        int s1 = 1, s2 = 2, s3 = 3;
        Console.Write("Enter Bonus: ");
        int bonus = int.Parse(Console.ReadLine());
        add_bonus(ref s1, ref s2, ref s3, bonus);
        Console.WriteLine("{0}, {1}, {2}",s1,s2,s3);
        Console.ReadKey();
    }
}
ข้อที่ 2
using System;
class MainClass
{
    static void swap(){

    }
    public static void Main(string[] args)
    {
        int sum = 0;
        Console.Write("Enter a: ");
        int a = int.Parse(Console.ReadLine());
        Console.Write("Enter b: ");
        int b = int.Parse(Console.ReadLine());
        swap();
        Console.WriteLine("Swap a and b");
        Console.WriteLine("a={0} b={1}",a,b);
        Console.ReadKey();
    }
}
ข้อ 3
using System;
class RefExample
{
    static void ReadTwoNums()
    {
        Console.WriteLine("Enter two number:");
        a = int.Parse(Console.ReadLine());
        b = int.Parse(Console.ReadLine());
    }
    static void Main()
    {
        int n1 = 0, n2 = 0;
        ReadTwoNums();
        Console.WriteLine("Numbers are {0} and {1}", n1, n2);
        Console.ReadKey();
    }
}

ข้อ 4
using System;
2: class MainClass {
3:     static void ReadPoint( )
4:     {
5: Console.Write("Enter x-coordinate: ");
6:             x = double.Parse(Console.ReadLine());
7:             Console.Write("Enter y-coordinate: ");
8:             y = double.Parse(Console.ReadLine());
9:     }
10:
11:     static double Distance( )
12:     {
13:            
14:     }
15:
16:     static void Main()
17:     {
18:             double ax, ay, bx, by;
19:             Console.WriteLine("Point A:");
20:             ReadPoint(out ax, out ay);
21:             Console.WriteLine("Point B:");
22:             ReadPoint(out bx, out by);
23:             Console.WriteLine("The distance between A and B is {0:f2}",
24:                               Distance(ax,ay,bx,by));
25:     }
26: }
ข้อ 5

using System;
class MainClass {
    static int Profit(int x)
    {
        
    }

    static void Main()
    {
        int a, b;
        Console.Write("Enter A:");
        a = int.Parse(Console.ReadLine());
        Console.Write("Enter B:");
        b = int.Parse(Console.ReadLine());

        int best = Profit(a);
        int bestAt = a;

        

        Console.WriteLine("Best profit is {0} at {1}", best, bestAt);
    }
}

ข้อ 6
using System;
class MainClass {
    static int h, d, n;

    /* this method checks if y is out of the well of depth h */
    static bool IsOut(int y, int h)
    {
       
    }

    static void ClimbUp(ref int y)
    {
       
    }

    static void FallDown(ref int y)
    {
       
    }

    static void Main()
    {
        h = int.Parse(Console.ReadLine());
        d = int.Parse(Console.ReadLine());
        n = int.Parse(Console.ReadLine());

        int day = 1;
        int y = 0;
        while(!IsOut(y,h))
        {
           
            day++;
        }
        Console.WriteLine("Get out on day {0}", day);
    }
}

ข้อ 7
using System;
class MainClass
{
    /* method IsSquare checks if y is a square. */
    static bool IsSquare(int y)
    {
        
    }

    /* method IsSquareFactor checks if f is a square factor of x */
    static bool IsSquareFactor(int f, int x)
    {
        
    }

    public static void Main(string[] args)
    {
        int x = int.Parse(Console.ReadLine());
        int i = 1;
        while()
        {
            if()
                Console.Write("{0} ", );
            i++;
        }
        Console.WriteLine();
    }
}

ข้อ 8
using System;

class Program
{
  static void CountPlusMinus()
  {
    
  }

  public static void Main(string[] args)
  {
    int plus, minus;
    CountPlusMinus();
    Console.WriteLine("Positive: {0}",plus);
    Console.WriteLine("Negative: {0}",minus);
    Console.ReadLine();
  }
}


ข้อ 9

ข้อ 10

ข้อ 11
using System;


namespace hellofile
{
    class Program
    {
        public static void Main(string[] args)
{
            StreamReader reader =
            int a = int.Parse();
            int b =
            int c =
            Console.WriteLine(a+b+c);
            Console.ReadLine();
            reader.
        }
    }
}

ข้อ 12
using System;
using System.IO;

namespace hellofile
{
    class Program
    {
        public static void Main(string[] args)
        {
            StreamReader reader = 
            int n = int.Parse();
            int i = 0;
            int total = 0;
            while(i < n)
            {
                
            }
            Console.WriteLine(total);
            Console.ReadLine();
            reader.Close();
        }
    }
}

ข้อ13
using System;
using System.IO;
namespace moving_average
{
  class Program
  {
    static void Update()
    {
      
    }

    public static void Main(string[] args)
    {
      StreamReader reader = new StreamReader("input.txt");
      int n = 0;
      double total = 0;
      double avr = 0;
      double x;
      do {
        x = double.Parse(reader.ReadLine());
        if(x != 0)
        {
          Update();
          Console.WriteLine("{0:f3} {1:f3}", total, avr);
        }
      } while();
      reader.Close();
      Console.ReadLine();
    }
  }
}

ข้อ 14

using System;
using System.IO;
namespace moving_average
{
  class Program
  {
    

    static void Update(double x)
    {
      
    }

    public static void Main(string[] args)
    {
      StreamReader reader = new StreamReader("input.txt");
      double x;
      do {
        x = double.Parse(reader.ReadLine());
        if(x != 0)
        {
          Update(x);
          Console.WriteLine("{0:f3} {1:f3}", total, avr);
        }
      } while();
      reader.Close();
      Console.ReadLine();
    }
  }
}

ข้อ 15

ข้อ 16



1.1-1.3

1.1
ref int s1, ref int s2, ref int s3, int bonus

s1 = s1 + bonus;
s2 = s2 + bonus;
s3 = s3 + bonus;

1.2
ref int a, ref int b

int x = a;
a = b;
b = x;

1.3
ref int a, ref int b
 ref n1 , ref n2

วันจันทร์ที่ 24 มกราคม พ.ศ. 2554

Lab 10 - เมธอด ภาค 2 (การส่งพารามิเตอร์) และการใช้งานไฟล์

using System;
class MainClass
{
    static void add_bonus(){
        
    }
    public static void Main(string[] args)
    {
        int s1 = 1, s2 = 2, s3 = 3;
        Console.Write("Enter Bonus: ");
        int bonus = int.Parse(Console.ReadLine());
        add_bonus(ref s1, ref s2, ref s3, bonus);
        Console.WriteLine("{0}, {1}, {2}",s1,s2,s3);
        Console.ReadKey();
    }
}
ข้อ 1.2
using System;
class MainClass
{
    static void swap(){

    }
    public static void Main(string[] args)
    {
        int sum = 0;
        Console.Write("Enter a: ");
        int a = int.Parse(Console.ReadLine());
        Console.Write("Enter b: ");
        int b = int.Parse(Console.ReadLine());
        swap();
        Console.WriteLine("Swap a and b");
        Console.WriteLine("a={0} b={1}",a,b);
        Console.ReadKey();
    }
}
ข้อที่ 1.3

using System;
class RefExample
{
    static void ReadTwoNums()
    {
        Console.WriteLine("Enter two number:");
        a = int.Parse(Console.ReadLine());
        b = int.Parse(Console.ReadLine());
    }
    static void Main()
    {
        int n1 = 0, n2 = 0;
        ReadTwoNums();
        Console.WriteLine("Numbers are {0} and {1}", n1, n2);
        Console.ReadKey();
    }
}
ข้อ 2


key lab com Bonus คิดด้วยนะ เวลา ลอกอะ

ข้อ 1
using System;
using System.Collections.Generic;
public class MyClass
{
 public static void Main()
 {

  Console.Write("A: ");
  int A = int.Parse(Console.ReadLine());
  Console.Write("B: ");
  int B = int.Parse(Console.ReadLine());
  int x = A*B;
  string S = x.ToString();
  string t = A.ToString();
  string u = B.ToString();
  string Y = S + A;
  string y = A + S;
  int a = int.Parse(Y);
  int b = int.Parse(y);
  int Sum = a-b;
  Console.WriteLine("{0} - {1} = {2}",a,b,Sum);
  Console.ReadLine();
 }
 
}


ข้อ 2

using System;
using System.Collections.Generic;
public class MyClass
{
 public static void Main()
 {
  Console.Write("Score: ");
  int Score = int.Parse(Console.ReadLine());
  Console.Write("Mean: ");
  int Mean = int.Parse(Console.ReadLine());
  if(Score>=Mean)
  {
  if((Score>Mean)&&(Score>=80))
         {
              Console.WriteLine("Grade A!");
        }
        else if (Score>Mean)
          {
               Console.WriteLine("Grade B!");
          }
        else
         {
              Console.WriteLine("Grade C!");
         }
  }
  else
  {
   if((Score<Mean)&&(Score<40))
          {
              Console.WriteLine("Grade F!");
         }
   else
          {
              Console.WriteLine("Grade D!");
          }
  }
 } 
}

ข้อ 3
 ----- 
ข้อ 4
---
ข้อ 5

using System;
using System.Collections.Generic;
public class MyClass
{
 static int Factorial(int n)
   {
  int sum = 1;
     while (n>0)
      {
      sum *= n;
      n= n-1;
      }
     return sum;
 }
 public static void Main()
 {
  Console.Write("A: ");
  int A = int.Parse(Console.ReadLine());
  long a = Factorial(A);
  Console.Write("B: ");
  int B = int.Parse(Console.ReadLine());
  long b = Factorial(B);
  Console.Write("C: ");
  int C = int.Parse(Console.ReadLine());
  long c = Factorial(C);
  long sum = a+b+c;
  if (((A>=0)&&(A<=20))&((B>=0)&&(B<=20))&((C>=0)&(C<=20)))
  {
  Console.WriteLine("{0}! + {1}! + {2}! = {3}",A,B,C,sum);
  }
  Console.ReadLine();
 }
}

ข้อ 3

using System;
class Program
{
    static void Main()
    {
         A = ;
        double B = 1 / 2;
         C = ;
         D = ;
        int E = 1;

        if (!(Math.Sin(A) != B || C == D || C))
            E--;

        Console.WriteLine(E);
    }
}
ข้อ อื่น รอไปก่อนนะ บางข้ออาจจะผิดพลาดบ้าง อย่าโวยวาย กำลังแก้ใขอยู๋

วันจันทร์ที่ 17 มกราคม พ.ศ. 2554

เฉลย ข้อ 6.1/6.2/6.3/7

6.1

static double f(int n)
 {
  double i = 1;
  double sum =0;
  while (i<=n)
  {
   sum += 1/i;
   i++;
  }
  return sum;
 }


6.2
int sum = 1;
   while (n>0)
   {
    sum *= n;
    n= n-1;
   }
   return sum;

6.3

double j = 0;
     double sum = 0;
     while (j<=k)
     {
      sum += 1/(double)(Factorial((int)j));
      j++;
     }
     return sum;

7
using System;
class x
{
  static int f(int n)
  {
   double sum = 20+10*Math.Sin(n/Math.PI);
   int sum1 = (int)Math.Round(sum);
   return  sum1;
  }
 
  static void PlotChar(int a , int b)
   {
   int i = 1;
 while (i<b)
 {
  Console.Write(" ");
  i++;
 }
 Console.WriteLine("*");
 }
 static void Main()
  {
    Console.WriteLine(" x|");
    Console.WriteLine("--+---------------------------------------> y");
   int i = 0;
   while (i<=20)
   {
    Console.Write("{0,2}|",i);
    PlotChar(' ',f(i));
    i++;
   }
   Console.Read();
  }
}

วันอังคารที่ 11 มกราคม พ.ศ. 2554

เมธอด 1

ข้อ1
CalRectangle(a,b);
CalSquare(c);
ข้อ 1.2
cal_rectangle(a,b)
cal_square(c);
ข้อ 1.3
static double CircleArea(double radius){
return Math.PI*radius*radius;
}
ข้อ 2
static void PrintLongerLine()
{
int i = 0;
while(i < 29)
{
Console.Write('*');
i++;
}
Console.WriteLine();
}

PrintLine();
PrintLongerLine();
PrintLine();
PrintLongerLine();

ข้อ 3
0000000000
********************
PrintCharLine('x',  10);
PrintCharLine('*',  20);
PrintCharLine('v',  30);
ข้อ 4 .1
h-(i+1)
i+1
ข้อ 4.2
using System;
class MainClass
{
    public static void PrintChar(char c, int len)
    {
        int i = 0;
        while(i < len)
        {
            Console.Write(c);
            i++;
        }
    }
    public static void Main(string[] args)
    {
        Console.Write("Enter height : ");
        int h = int.Parse(Console.ReadLine());
        int i = 0;
        while(i < h)
        {
            PrintChar('-', i);
            PrintChar('x', h-i);
            Console.WriteLine();
            i++;
        }
    }
}
ข้อ 5
int i = 1;
     while(i<dist)
     {
      Console.Write(' ');
      i++;
     }
     Console.WriteLine(c);
ข้อ 6.1

ข้อ 6.2

ข้อ 6.3

ข้อ 7

วันจันทร์ที่ 10 มกราคม พ.ศ. 2554

ช่วยกันแท็ก หน่อยเร็ว ใครรู้จักพี่คนใหนแล็กเลย พี่เบลช่วยแท็กไป เกือบร้อยคนแระ ช่วยยกันทำเร็ว

http://www.facebook.com/photo.php?pid=216702&id=100001626990247&op=1&view=global&subj=116262051744820#!/photo.php?pid=216697&id=100001626990247&notif_t=photo_tagged_by_non_owner



ช่วยกันแท็ก หน่อยเร็ว ใครรู้จักพี่คนใหนแล็กเลย  พี่เบลช่วยแท็กไป เกือบร้อยคนแระ ช่วยยกันทำเร็ว

แผนการศึกษา ปรับปรุง 11 มกราคม 2554

แผนการศึกษา
ปีการศึกษาที่ 1 ภาคการศึกษาที่ 1                                             จำนวนหน่วยกิต(บรรยาย-ปฏิบัติการ)
01208111  การเขียนแบบวิศวกรรม                                                                                               3(2-3)
01420111  ฟิสิกส์ทั่วไป 1                                                                                                                3(3-0)
01420113  ปฏิบัติการฟิสิกส์ทั่วไป 1                                                                                              1(0-3)
01999021  ภาไทยเพื่อการสื่อสาร                                                                                                              3(3-0)
01355111  ภาษาอังกฤษ 1                                                                                                               0(3-0)
                                                                                                                                               รวม        10( - )  หน่วยกิต
ปีการศึกษาที่ 1 ภาคการศึกษาที่ 2                                            จำนวนหน่วยกิต(บรรยาย-ปฏิบัติการ)
01417167 คณิตศาสตร์วิศวกรรม 1                                                                                                 4(4-0)
01204111 คอมพิวเตอร์และการโปรแกรม                                                                                    3(2-3)
01403114  ปฏิบัติการหลักมูลเคมีทั่วไป                                                                                        1(0-3)
01999033  ศิลปะการอยู่ร่วมกับผู้อื่น                                                                                              3(3-0)
01387101  ศิลปะการอยู่ร่วมกับผู้อื่น และอื่น ๆ                                                                          3(3-0)
01355112  ภาษาอังกฤษ 2                                                                                                               3(3-0)
01175127  ฮอกกี้                                                                                                                                1(0-2)
01175151  ดาบไทย                                                                                                                           1(0-2)                                                                                                                                                                    รวม      19( - )  หน่วยกิต


ปีการศึกษาที่ 1 ภาคการศึกษา ภาคฤดูร้อน                               จำนวนหน่วยกิต(บรรยาย-ปฏิบัติการ)
01417168  คณิตศาสตร์วิศวกรรม 2                                                                                                3(3-0)
01403117  หลักมูลเคมีทั่วไป                                                                                                           3(3-0)
                                                                                                                                                รวม        7( - )  หน่วยกิต

ปีการศึกษาที่ 2 ภาคการศึกษาที่ 1                                             จำนวนหน่วยกิต(บรรยาย-ปฏิบัติการ)
01208221 กลศาสตร์วิศวกรรม 1                                                                                                    3(3-0)
01213211 วัสดุศาสตร์สำหรับวิศวกร                                                                                             3(3-0)
01417267 คณิตศาสตร์วิศวกรรม 3                                                                                 3(3-0)
01355113 ภาษาอังกฤษ 3                                                                                                                 3(3-0)
01999141 มนุษย์กับสังคม                                                                                                                3(3-0)
                                                                                                                                                รวม    18 ( - ) หน่วยกิต








ปีการศึกษาที่ 2 ภาคการศึกษาที่ 2                                                         จำนวนหน่วยกิต(บรรยาย-ปฏิบัติการ)
01203211 การสำรวจ                                                                                                                         3(2-3)
01203221 กลศาสตร์ของวัสดุ 1                                                                                                       3(3-0)
01209211 กลศาสตร์ของไหล                                                                                                          3(3-0)
01209241 หลักอุทกวิทยา                                                                                                                 3(3-0)                   
01****** Man & sea                                                                                                                        3(3-0)
01355114 ภาษาอังกฤษ 4                                                                                                                 3(3-0)
01999213 สิ่งแวดล้อมเทคโนโลยีและชีวิต                                                                                   3(3-0)
                                                                                                                                                รวม    21( - ) หน่วยกิต
               
ปีการศึกษาที่ 2 ภาคการศึกษา ภาคฤดูร้อน                                    จำนวนหน่วยกิต(บรรยาย-ปฏิบัติการ)
01420112  ฟิสิกส์ทั่วไป 2                                                                                                                3(3-0)
01417268 คณิตศาสตร์วิศวกรรม 4                                                                                 3(3-0)
01420114  ปฏิบัติการฟิสิกส์ทั่วไป 2                                                                                              1(0-3)
                                                                                                                          รวม    7( - ) หน่วยกิต




ปีการศึกษาที่ 3 ภาคการศึกษาที่ 1                                                 จำนวนหน่วยกิต(บรรยาย-ปฏิบัติการ)
01203212 การฝึกงานสำรวจ                                                                                                            1
01203222 การวิเคราะห์โครงสร้าง 1                                                                                           3(3-0)
01203223 กลศาสตร์ของวัสดุ 2                                                                                                       3(3-0)
01203322 ทดสอบวัสดุโยธา                                                                                                            1(0-3)
01203332 คอนกรีตและวัสดุวิศวกรรม                                                                                          3(3-0)
01209312 ปฏิบัติการสำหรับวิชากลศาสตร์ของไหล                                                  1(0-3)
01209321 การไหลในทางน้ำเปิด                                                                                                    3(3-0)
01209342 อุทกวิทยาประยุกต์                                                                                                          3(2-3)
01209343 การพัฒนาทรัพยากรน้ำเบื้องต้น                                                                                  3(3-0)
                                                                                                                                                รวม     21( - ) หน่วยกิต
ปีการศึกษาที่ 3 ภาคการศึกษาที่ 2                                                 จำนวนหน่วยกิต(บรรยาย-ปฏิบัติการ)
01203323 การวิเคราะห์โครงสร้าง 2                                                                                             3(3-0)
01203331 การออกแบบคอนกรีตเสริมเหล็ก                                                                                3(3-0)
01203352 ปฐพีกลศาสตร์                                                                                                                 3(3-0)
01203352 ปฏิบัติการปฐพีกลศาสตร์                                                                                              1(0-3)
01203361 วิศวกรรมก่อสร้างและการจัดการ                                                                                3(3-0)
01209332 วิศวกรรมชายฝั่งทะเล                                                                                                    3(3-0)
01209346 น้ำใต้ดิน                                                                                                                            3(3-0)
                                                                                                                                                รวม      19( - )  หน่วยกิต
ปีการศึกษาที่ 4 ภาคการศึกษาที่ 1                                                 จำนวนหน่วยกิต(บรรยาย-ปฏิบัติการ)
01203333 การออกแบบโครงสร้างไม้และเหล็ก                                                                          3(2-3)
01203417 วิศวกรรมการทาง                                                                                                       3(3-0)
01209423 วิศวกรรมชลศาสตร์                                                                                                    3(3-0)                   
01209428 แคดทางวิศวกรรมทรัพยากรน้ำ                                                                                    3(3-0)
01209444 การวางแผนโครงการทรัพยากรน้ำ                                                                               3(3-0)
01209461 วิศวกรรมทรัพยากรน้ำและสิ่งแวดล้อม                                                                        3(3-0)
01209495 การเตรียมงานโครงงานวิศวกรรมทรัพยากรน้ำ                                                           1(0-3)
                                                                                                                                                รวม  19 (17-6) หน่วยกิต 

                ปีการศึกษาที่ 4 ภาคการศึกษาที่ 2                                                 จำนวนหน่วยกิต(บรรยาย-ปฏิบัติการ)
01209424 การออกแบบอาคารชลศาสตร์                                                                                          3(3-0)
01209463 การจัดการทรัพยากรน้ำ                                                                                                    3(3-0)
01209467 สัมมนา                                                                                                                              1
01209499 โครงงานวิศวกรรมทรัพยากรน้ำ                                                                                         2(0-6)
01209494 การศึกษาภาคสนามด้านวิศวกรรมทรัพยากรน้ำ                                                                    1(0-3)
01209455 เทคโนโลยีสารสนเทศสำหรับวิศวกรรมทรัพยากรน้ำ                                                           3(3-0)
                                                                                                                                                รวม 13 ( - ) หน่วยกิต