نمونه سوالات محیط کنسول (بخش چهارم)

نمونه سوالات محیط کنسول (بخش چهارم)

تمرین های برنامه نویسی محیط کنسول جلسه ی ششم (چهارشنبه 94.09.13)

 

 

سوالات :

1- برنامه ای بنویسید که چهار عدد را از ورودی گرفته،  آن ها را داخل آرایه قرار داده :

الف) توان سوم هر عدد را نمایش دهد.

ب) جذر هر عدد موجود در آرایه را نیز نمایش دهد.

2- برنامه ای بنویسید که یک آرایه ی 3,2 را از ورودی گرفته، از نوع کاراکتر _ تک تک کاراکترهای موجود در آرایه را کنار هم نمایش دهد.

3- برنامه ای بنویسید که 2 آرایه ی 2,2 را از ورودی گرفته، حاصل تفریق آن ها را نمایش دهد.

 

عنوان درس : برنامه سازی شبکه

استاد مربوطه : مهندس رضاپور

برنامه نویس : تقی سیفی

 

پاسخ سوالات در ادامه مطلب !

 

جواب سوال اول :

int [] x = new int [4];

            for (int i = 0; i <= 3; i++)

                x[i] = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i <= 3; i++)

                Console.WriteLine(Math.Pow(x[i],3));

            for (int i = 0; i <= 3; i++)

                Console.WriteLine(Math.Sqrt(x[i]));


            Console.ReadKey();

 

-------------------------------------------------------

جواب سوال دوم :

 

char [,] x = new char [3,2];

            x[0, 0] = Convert.ToChar(Console.ReadLine());
            x[0, 1] = Convert.ToChar(Console.ReadLine());
            x[1, 0] = Convert.ToChar(Console.ReadLine());
            x[1, 1] = Convert.ToChar(Console.ReadLine());
            x[2, 0] = Convert.ToChar(Console.ReadLine());
            x[2, 1] = Convert.ToChar(Console.ReadLine());

            Console.Write(x[0,0]);
            Console.WriteLine(x[0,1]);
            Console.Write(x[1,0]);
            Console.WriteLine(x[1,1]);
            Console.Write(x[2,0]);
            Console.WriteLine(x[2,1]);



            Console.ReadKey();

 

-------------------------------------------------------

 

جواب سوال سوم :

 

int [,] x = new int [2,2];

int[,] y = new int[2, 2];
            

            x[0, 0] = Convert.ToInt32(Console.ReadLine());
            x[0, 1] = Convert.ToInt32(Console.ReadLine());
            x[1, 0] = Convert.ToInt32(Console.ReadLine());
            x[1, 1] = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine();
            
            y[0, 0] = Convert.ToInt32(Console.ReadLine());
            y[0, 1] = Convert.ToInt32(Console.ReadLine());
            y[1, 0] = Convert.ToInt32(Console.ReadLine());
            y[1, 1] = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine();

            Console.Write(x[0,0]-y[0,0]);
            Console.Write(x[0,1]-y[0,1]);
            Console.Write(x[1,0]-y[1,0]);
            Console.Write(x[1,1]-y[1,1]);
            

           Console.ReadKey();

2 نظر

  1. LatriciaLatricia:

    We col&#039;vude done with that insight early on.

  2. LorinLorin:

    Thanks for that! It&#039;s just the answer I neddee.

ارسال نظر برای این مطلب غیر فعال شده است!