الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

أينَ المشكلَـه فالـ Arrar & function

بدأه Immortality في 3 أبريل 2011 · 0 رد · 291 مشاهدة · في قسم البرمجة بــ Javascript
مشاركة: واتساب X فيسبوك تيليجرام
#1

السَـلام عليكم و رحمَـه الله وبركَـاته . .

ياجَماعَـة عندي كود فـ الـ array

وكتَبتهْ بس المشكَله ما يظهر لي الـ out put

مدري وين المشكلـَه بالضّبط . .

هذا السّؤال . .

Array

T T F F F T F T F F

0 1 2 3 4 5 6 7 8 9

Set A :

Set A = { 0 , 1 , 5 , 7 }

F T T F T F F T T F

0 1 2 3 4 5 6 7 8 9

Set B

Set B = { 1 , 2 , 4 , 7 , 8 }

Result of Union = { 0 , 1 , 2 , 4 , 5 , 7 , 8 }

Result of intersection = { 1 , 7 }

Result of difference = { 0, 2 , 5, 8 }

وهذّا الكود مالي

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
  <script type="text/javascript" >

function isEmpty(arr)
     {
        var c = 0;
        for(var ctr=0; ctr < arr.length; ctr++)
          {
            if (arr[ctr]==true)
              c++;
          }
       if (c > 0)
         return false;
       else
         return true;     
     }


   function display(arr)
     {
        document.write("{ ");
        for(var ctr=0;ctr<arr.length; ctr++)
          {
           if (arr[ctr] == true)
              document.write(ctr + ",");
          }
          document.write(" } ");
     }


     } 
    var setA = new Array(false, false, false, false,false,false, false, false, false, false);

 display(setA);

    var setB = new Array(false, true, true, false,true,false, false, true, true, false);

    display(setB);
     	 document.write("<br />"); document.write("is SEt A empty? " + isEmpty(setA));document.write(" <br />");


//  function union

	   function union(arr)
     {
        document.write("{ ");
        for(var ctr=0;ctr<arr.length; ctr++)
          {
           if (arr[ctr] == true && arr[ctr] == false )
              document.write(ctr + ",");
          }
          document.write(" } ");

	    var setA = new Array(true, true, false, false,false,true, false, true, false, false);

 display(setA);

    var setB = new Array(false, true, true, false,true,false, false, true, true, false);

    display(setB);
     	  document.write("the union is : " function union(arr));




  </script>
</body>
</html>

و الintersection difference ما عَرفت كيف احطهم بالكودَ :wacko:

اتمنَى تسَاعدوني فيـه وبكون شاكرَة لكم

تم تعديل هذه المشاركة بواسطة Immortality في 3 أبريل 2011 في 01:46

مواضيع مشابهة