using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace homework
{
class Program
{
public static string[,] employees = {{"moayed","2500"},{"ali","1500"},{"nabiel","2000"},{"belal","3000"},{"kaled","1700"},{"rian","2500"} };
static void Main(string[] args)
{
for (int i = 0; i < 6; i++)
for (int y = 0; y < 1; y++)
Console.WriteLine(employees[i, 0] + " " + employees[y, 1] + "\n");
for (int i = 0; i < 6; i++) // Array Sorting
{
for (int j = 1 - 1; j > 0; j--)
{
for (int k = 0; k < j; k++)
{
if (employees[i, k] > employees[i, k + 1])
{
int temp = employees[i, k];
employees[i, k] = employees[i, k + 1];
employees[i, k + 1] = temp;
}
}
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}مساعدة لحل مشكلة في البرنامج
اخى الكريم... انا حليت كودك وتفضل هذا الكود الجديد
using System;
using System.Collections.Generic;
using System.Text;
namespace homework
{
class Program
{
public static string[,] employees = { { "moayed", "2500" }, { "ali", "1500" }, { "nabiel", "2000" }, { "belal", "3000" }, { "kaled", "1700" }, { "rian", "2500" } };
static void Main(string[] args)
{
for (int i = 0; i < 6; i++)
for (int y = 0; y < 1; y++)
Console.WriteLine(employees[i, 0] + " " + employees[y, 1] + "\n");
for (int i = 0; i < 6; i++) // Array Sorting
{
for (int j = 1 - 1; j > 0; j--)
{
for (int k = 0; k < j; k++)
{
if (Convert.ToInt32(employees[i, k]) > Convert.ToInt32(employees[i, k + 1]))
{
int temp = Convert.ToInt32(employees[i, k]);
employees[i, k] = employees[i, k + 1];
employees[i, k + 1] = Convert.ToString(temp);
}
}
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}اتمنى لك التوفيق... وشكرا
تم تعديل هذه المشاركة بواسطة صوت الماضى في 14 ديسمبر 2011 في 18:09
لكن هناك مشكلة اخرى لم يتم ترتيب المصفوفة ابجديا
السلام عليكم ورحمه الله وبركاته
اخي ممكن توضح ايش المشكلة؟!!
.:: Wish to become better and better ::.
جرب هذا الكود.... اى نعم هو مختلف عن الكود بتاعك.... بس حل كل مشاكلك
using System;
using System.Collections.Generic;
using System.Text;
namespace homework
{
class Program
{
public static string[] Key = { "moayed", "ali", "nabiel", "belal", "kaled", "rian" };
public static string[] Values ={ "2500", "1500", "2000", "3000", "1700", "2500" };
static void Main(string[] args)
{
Array.Sort(Key, Values);
string result = null;
for (int i = 0; i < Key.Length; i++)
{
Console.WriteLine(result + Key.ToString() + " " + Values.ToString() + "\n");
}
Console.ReadLine();
}
}
}اتمنى لك التوفيق.... وشكرا
تم تعديل هذه المشاركة بواسطة صوت الماضى في 14 ديسمبر 2011 في 21:35
مشكورررر جدا واسف على الرد المتأخر