Jumat, 23 November 2007

Jawaban Quiz PT.Gudang informatika


using System;


using System.Collections.Generic;


using System.Text;


namespace ConsoleApplication6


{


class Program


{


public static int maxangka = 999;


public static int AlphabetMax = 90;


public static int AlphabetMin = 65;



static void Main(string[] args)


{


// SoalNo1();


//Alphabet 65-90


SoalNo1();


Console.ReadLine();


SoalNo2(000);


Console.ReadLine();


}



static void SoalNo2(int angkanya)


{


if (angkanya <= 999+3)


{


if (angkanya <= maxangka)


{


string tmpstr = angkanya.ToString().PadLeft(3, Convert.ToChar("0"));


PrintHurufOnebyOne(65);


Console.Write(tmpstr);


Console.Write(",");


}


if (angkanya==1000)


{


PrintHurufOnebyOne2(66);


}


if (angkanya == 1001)


{


PrintHurufOnebyOne3(66);


}


if (angkanya == 1002)


{


PrintHurufOnebyOne4(66);


}



 




SoalNo2(angkanya + 1);


}


}



static void PrintHurufOnebyOne(int huruf)


{


if (huruf >= 65 && huruf <= 90)


{


char theletter = Convert.ToChar(huruf);


string tmpstr = theletter.ToString().PadLeft(3, Convert.ToChar("A"));


Console.Write(tmpstr);


}


}


static void PrintHurufOnebyOne2(int huruf)


{


if (huruf > 65 && huruf <= 90)


{


char theletter = Convert.ToChar(huruf);


string tmpstr = "AA" + theletter.ToString();


Console.Write(tmpstr);


Console.Write("999");


Console.Write(",");


PrintHurufOnebyOne2(huruf + 1);


}


}


static void PrintHurufOnebyOne3(int huruf)


{


if (huruf > 65 && huruf <= 90)


{


char theletter = Convert.ToChar(huruf);


char minalphabet = Convert.ToChar(AlphabetMin);


char maxalphabet = Convert.ToChar(AlphabetMax);


string tmpstr = minalphabet.ToString() + theletter.ToString() + maxalphabet.ToString();


Console.Write(tmpstr);


Console.Write("999");


Console.Write(",");


PrintHurufOnebyOne3(huruf + 1);


}


}


static void PrintHurufOnebyOne4(int huruf)


{


if (huruf > 65 && huruf <= 90)


{


char theletter = Convert.ToChar(huruf);


string tmpstr = theletter.ToString().PadRight(3, Convert.ToChar(AlphabetMax));


Console.Write(tmpstr);


Console.Write("999");


Console.Write(",");


PrintHurufOnebyOne4(huruf + 1);


}


}


private static void SoalNo1()


{


int @switch = 5;


int banding = @switch;


int max = 1000;


string delimiter = "*";


for (int a = 1; a <= 1000; a++)


{


Console.Write(a);


if (a == banding)


{


int coba = (@switch == 3) ? @switch = 5 : @switch = 3;


Console.Write(delimiter);


banding += @switch;


}


}


Console.ReadLine();


}


}


}

Tidak ada komentar: