Sunday, October 19, 2014

Code Hunt Solutions 8

8.01- public static int Factorial(int x) {
if (x == 1)
return 1;
return x*Factorial(x-1);
}
public static int Puzzle(int i, int j) {
int sum = 0;
for (int s=i; s<=j; s++)
sum += Factorial(s);
return sum;
}
8.02-  string output = "";
        for(int i = 1; i <= n; i++){
            output += new string('#', i) + " ";
        }
        return output;
8.03- string output = "";
for(int i = n; i >= 0; i--){

           for(int a = 0; a <= n - i; a++){
output += a;
}
output += new string('_', i ) + " ";
        }
        return output;
8.04- string r = "";
for (int i = 0; i < n; i++){


for (int a = 0; a < n; a++){
if (i == a){
r += "-";
} else {

r += b;
}
}
r += " ";
}
return r.Trim();
8.05-  string r = "";
for (int i = 0; i < a.Length; i++){


for (int b = 0; b < a.Length; b++){
if (i == b){
r += "_";
} else {

r += a[b];
}
}
r += " ";
}
return r.Trim();
8.06-string r = "";
for (int i = 0; i < size; i++){


for (int b = 0; b < size; b++){
if ((i == 0 || i == size -1 ) || (b == 0 || b == size -1) ){
r += "$";
} else   {


r += "_";
}
}
r += " ";
}
return r.Trim();
8.07- string output = "";
string next = "x";
        for(int i = 0; i < height; i++){

if (i % 2 == 0){
next = "x";
} else {
next = "o";
}

            for(int b = 0; b < width; b++){


output += next;
if (next == "x")
next = "o";
else
next = "x";
if ((b +1) % width == 0)
output += " ";
}

        }
        return output.Trim();
8.08-    string output = "";

        for(int i=1; i<=number; i++){
                output += new string(i.ToString()[0], i)   + " ";
        }
for(int i=number -1 ; i>0; i--){
                output += new string(i.ToString()[0], i)   + " ";
        }
        return output.Trim();

1 comment:

  1. the king casino | jancasino.com
    The King Casino is a premier gaming destination dafabet in the entertainment industry. Get a chance to ボンズ カジノ win real money and start winning. 더킹카지노 Play casino games and

    ReplyDelete