var numEx1 = 7;  // Число заданий первого зачетного класса
var numEx2 = 7;  // Число заданий второго зачетного класса
var numEx3 = 8;  // Число заданий третьего зачетного класса

// room -- имя экземпляра зачетного класса
// fun  -- основа имени у функции
// num  -- число заданий
function showEx(room, fun, num)
{
  var str = "<P><TABLE border=0 cellspacing=0 cellpadding=5>"
  for(var i = 1; i <= num; i++)
  {
    str += "<TR valign=top><TD>"+i+".</TD><TD class=ramkat><PRE>"+
      eval(fun+"["+(i-1)+"]")+"</PRE></TD><TD>"+
      "<INPUT type=text size=14 maxlength=14 name=T"+i+
      " onkeypress='if(event.keyCode==13) {ret=false;"+
      "if(this.value=="+fun+i+"()) ret = true;"+room+
      ".Answer = ret ? "+room+".Yes : "+room+".No;"+room+
      ".Check(this.form,"+i+");}'><BR>"+
      "<INPUT type=button value=Проверить"+
      " onclick='if(this.form.T"+i+".value=="+fun+i+"())"+room+
      ".Answer="+room+".Yes;"+
      "else "+room+".Answer="+room+".No;"+room+
      ".Check(this.form,"+i+");'>"+
      "<INPUT type=text size=14 name=result"+i+" readonly><BR><BR></TD></TR>";
  }
  str +="</TABLE>";
  return str;
}

function ex11()
{
  var x = 5;
  var s = 0;
  while(x) {s += x; x--;}
  return s;
}

function ex12()
{
  var x = 5;
  var s = 0;
  while(--x) s += x;
  return s;
}

function ex13()
{
  var x = 5;
  var s = 0;
  while(x--) s += x;
  return s;
}

function ex14()
{
  var x = 5;
  var s = 0;
  while(s) s += x;
  return s;
}

function ex15()
{
  var x = 5;
  var s = 0;
  while(!x) s += x;
  return s;
}

function ex16()
{
  var x = 5;
  var s = 0;
  while(--x) s += x; s++;
  return s;
}

function ex17()
{
  var x = 5;
  var s = 0;
  while(--x && s <10) s += x;
  return s;
}

function ex21()
{
  var x = 5;
  var s = 0;
  while(--x || s <10) s += x;
  return s;
}

function ex22()
{
  var x = 5;
  var s = 0;
  while(--x || !s) s += x;
  return s;
}

function ex23()
{
  var x = 5;
  var s = 0;
  while(--x && s) s += x;
  return s;
}

function ex24()
{
  var s = 0;
  for(var i=1; i<10; i++) s += i;
  return s;
}

function ex25()
{
  var s = 0;
  for(var i=1; i<10; i+=2) s += i;
  return s;
}

function ex26()
{
  var s = 0;
  for(var i=10; i; i--) s += i;
  return s;
}

function ex27()
{
  var s = 0;
  for(var i=10; --i;) s += i;
  return s;
}

function ex31()
{
  var s = 0;
  for(var i=10; i--;) s += i;
  return s;
}

function ex32()
{
  var s = 0;
  for(var i=10;;)
  {if(--i) break; s += i;}
  return s;
}

function ex33()
{
  var s = 0;
  var i = 10;
  for(;;)
  {if(!(--i)) break; s += i;}
  return s;
}

function ex34()
{
  var s = 0;
  var i = 10;
  for(;;)
  {if(s > 6) break; s += --i;}
  return s;
}

function ex35()
{
  var s = 0;
  for(var i = 10;--i; s += i);
  return s;
}

function ex36()
{
  var s = 0;
  for(var i = 10;--i;)
  {if(i>5) continue; s +=i;}
  return s;
}

function ex37()
{
  var s = 0;
  var i = 10;
  while(--i)
  {if(i>5) continue; s +=i;}
  return s;
}

function ex38()
{
  var s = 0;
  var i = 10;
  while(--i)
  {if(i<5) break; s +=i;}
  return s;
}

var ex1 = new Array(

"<B>var</B> x = 5;<BR><B>var</B> s = 0;<BR><B>while</B>(x) {s += x; x--;}<BR>alert(s);",
"<B>var</B> x = 5;<BR><B>var</B> s = 0;<BR><B>while</B>(--x) s += x;<BR>alert(s);",
"<B>var</B> x = 5;<BR><B>var</B> s = 0;<BR><B>while</B>(x--) s += x;<BR>alert(s);",
"<B>var</B> x = 5;<BR><B>var</B> s = 0;<BR><B>while</B>(s) s += x;<BR>alert(s);",
"<B>var</B> x = 5;<BR><B>var</B> s = 0;<BR><B>while</B>(!x) s += x;<BR>alert(s);",
"<B>var</B> x = 5;<BR><B>var</B> s = 0;<BR><B>while</B>(--x) s += x; s++;<BR>alert(s);",
"<B>var</B> x = 5;<BR><B>var</B> s = 0;<BR><B>while</B>(--x && s <10) s += x;<BR>alert(s);"
                   );

var ex2 = new Array(
"<B>var</B> x = 5;<BR><B>var</B> s = 0;<BR><B>while</B>(--x || s <10) s += x;<BR>alert(s);",
"<B>var</B> x = 5;<BR><B>var</B> s = 0;<BR><B>while</B>(--x || !s) s += x;<BR>alert(s);",
"<B>var</B> x = 5;<BR><B>var</B> s = 0;<BR><B>while</B>(--x && s) s += x;<BR>alert(s);",
"<B>var</B> s = 0;<BR><B>for</B>(<B>var</B> i=1; i<10; i++) s += i;<BR>alert(s);",
"<B>var</B> s = 0;<BR><B>for</B>(<B>var</B> i=1; i<10; i+=2) s += i;<BR>alert(s);",
"<B>var</B> s = 0;<BR><B>for</B>(<B>var</B> i=10; i; i--) s += i;<BR>alert(s);",
"<B>var</B> s = 0;<BR><B>for</B>(<B>var</B> i=10; --i;) s += i;<BR>alert(s);"
                   );

var ex3 = new Array(
"<B>var</B> s = 0;<BR><B>for</B>(<B>var</B> i=10; i--;) s += i;<BR>alert(s);",
"<B>var</B> s = 0;<BR><B>for</B>(<B>var</B> i=10;;)<BR>{<B>if</B>(--i) <B>break</B>; s += i;}<BR>alert(s);",
"<B>var</B> s = 0;<BR><B>var</B> i = 10;<BR><B>for</B>(;;)<BR>{<B>if</B>(!(--i)) <B>break</B>; s += i;}<BR>alert(s);",
"<B>var</B> s = 0;<BR><B>var</B> i = 10;<BR><B>for</B>(;;)<BR>{<B>if</B>(s > 6) <B>break</B>; s += --i;}<BR>alert(s);",
"<B>var</B> s = 0;<BR><B>for</B>(<B>var</B> i = 10;--i; s += i);<BR>alert(s);",
"<B>var</B> s = 0;<BR><B>for</B>(<B>var</B> i = 10;--i;)<BR>{<B>if</B>(i>5) <B>continue</B>; s +=i;}<BR>alert(s);",
"<B>var</B> s = 0;<BR><B>var</B> i = 10;<BR><B>while</B>(--i)<BR>{<B>if</B>(i>5) <B>continue</B>; s +=i;}<BR>alert(s);",
"<B>var</B> s = 0;<BR><B>var</B> i = 10;<BR><B>while</B>(--i)<BR>{<B>if</B>(i<5) <B>break</B>; s +=i;}<BR>alert(s);"
                   );
