示例#1
0
文件: main.c 项目: amaceh/KULIAH
int main()
{
	stack S1;
	stack S2;

	char ngaran[5][10];

	CreateEmpty(&S1);
	CreateEmpty(&S2);
	int i;
	for(i=0 ; i<5 ; i++){
		scanf("%s", ngaran[i]);
	}
	printf("S1 -");
	printstack(S1);
	printf("S2 -");
	printstack(S2);
	push(ngaran[0], &S1);
	push(ngaran[1], &S2);
	spop(&S1, &S2);
	printf("S1 -");
	printstack(S1);
	printf("S2 -");
	printstack(S2);
	pop(&S2);
	push(ngaran[2], &S1);
	push(ngaran[3], &S2);
	push(ngaran[4], &S2);
	spop(&S2, &S1);
	printf("S2 -");
	printstack(S2);
	printf("S1 -");
	printstack(S1);
	return 0;
}
示例#2
0
int main()
{	/* KAMUS */
	int pilihan ;
	char X;
	Stack S;
	char str[100];
	
	/* ALGORITMA */
	CreateEmpty(&S);
	do
	{
		printf("\n***** MENU PILIHAN *****\n");
		printf("1. Mengosongkan stack\n");
		printf("2. Menambah satu elemen stack\n");
		printf("3. Menghapus satu elemen stack\n");
		printf("4. Konversi Stack ke String\n");
		printf("0. Keluar\n");
		printf("Masukan pilihan : ");
		scanf("%d%*c",&pilihan);
		printf("\n");
		switch(pilihan)
		{
			case 1 : CreateEmpty(&S);
					 printf("Stack telah menjadi kosong.\n");
					 break;
			case 2 : printf("Masukan nilai yang akan ditambahkan ke stack : ");
					 scanf("%c",&X);
					 Push(&S,X);
					 printf("Nilai %c berhasil ditambahkan.\n",InfoTop(S));
					 break;
			case 3 : if(IsEmpty(S))
					 	printf("Maaf stack sudah kosong, tidak bisa menhapus elemen lagi.\n");
					 else
					 {
					 	Pop(&S,&X);
					 	printf("Nilai %c berhasil dihapus.\n", X);
					 }
					 break;
			case 4 : StackToString(&S,str);
					 printf("Isi stack diubah menjadi string adalah sebagai berikut :\n%s\n", str);
					 break;
					
			default :
					 printf("Driver berakhir.\n\n");
		}
	} while(pilihan > 0 && pilihan < 5);
	return 0;
}
pugi::xml_node CXmlFile::Load()
{
	Close();
	m_error.clear();

	wxCHECK(!m_fileName.empty(), m_element);

	std::wstring redirectedName = GetRedirectedName();

	GetXmlFile(redirectedName);
	if (!m_element) {
		wxString err = wxString::Format(_("The file '%s' could not be loaded."), m_fileName);
		if (m_error.empty()) {
			err += wxString(_T("\n")) + _("Make sure the file can be accessed and is a well-formed XML document.");
		}
		else {
			err += _T("\n") + m_error;
		}

		// Try the backup file
		GetXmlFile(redirectedName + _T("~"));
		if (!m_element) {
			// Loading backup failed. If both original and backup file are empty, create new file.
			if (fz::local_filesys::get_size(fz::to_native(redirectedName)) <= 0 && fz::local_filesys::get_size(fz::to_native(redirectedName + _T("~"))) <= 0) {
				m_error.clear();
				CreateEmpty();
				m_modificationTime = fz::local_filesys::get_modification_time(fz::to_native(redirectedName));
				return m_element;
			}

			// File corrupt and no functional backup, give up.
			m_error = err;
			m_modificationTime.clear();
			return m_element;
		}


		// Loading the backup file succeeded, restore file
		bool res;
		{
			wxLogNull null;
			res = wxCopyFile(redirectedName + _T("~"), redirectedName);
		}
		if (!res) {
			// Could not restore backup, give up.
			Close();
			m_error = err.ToStdWstring();
			m_error += _T("\n") + wxString::Format(_("The valid backup file %s could not be restored"), redirectedName + _T("~")).ToStdWstring();
			m_modificationTime.clear();
			return m_element;
		}

		// We no longer need the backup
		wxRemoveFile(redirectedName + _T("~"));
		m_error.clear();
	}

	m_modificationTime = fz::local_filesys::get_modification_time(fz::to_native(redirectedName));
	return m_element;
}
示例#4
0
/**
 * @brief Create a line.
 * @param [in] pszLine Line data.
 * @param [in] nLength Line length.
 */
void LineInfo::Create(LPCTSTR pszLine, int nLength)
{
  if (nLength == 0)
    {
      CreateEmpty();
      return;
    }

  m_nLength = nLength;
  m_nMax = ALIGN_BUF_SIZE (m_nLength + 1);
  ASSERT (m_nMax >= m_nLength + 1);
  if (m_pcLine != NULL)
    delete[] m_pcLine;
  m_pcLine = new TCHAR[m_nMax];
  ZeroMemory(m_pcLine, m_nMax * sizeof(TCHAR));
  const DWORD dwLen = sizeof (TCHAR) * m_nLength;
  CopyMemory (m_pcLine, pszLine, dwLen);
  m_pcLine[m_nLength] = '\0';

  int nEols = 0;
  if (nLength > 1 && IsDosEol(&pszLine[nLength - 2]))
    nEols = 2;
  else if (nLength && IsEol(pszLine[nLength - 1]))
    nEols = 1;
  m_nLength -= nEols;
  m_nEolChars = nEols;
}
示例#5
0
task main()
{
	Queue Q;
	CreateEmpty(&Q);
	int color = searchSpot();
	if(color==green) {
		stepAhead(220);
		turn(right,20);
		cekSimpang(&Q);
	}
	BFS(first,&Q);
}
示例#6
0
void insertjumlahpemain(player *p, Queue *Q)
{
    int i;
    printf("Jumlah pemain : ");
    scanf("%d", &(*p).jmlpemain);
    CreateEmpty(&(*Q), (*p).jmlpemain);
    for(i=1;i<=(*p).jmlpemain;i++)
    {
        printf("Nama Pemain %d : ", i);
        scanf("%s", &(*p).pem[i].nama);
        Add(&(*Q), i);
    }
}
示例#7
0
void CreateQueuePemain(Queue *Q, int Maks)
/* I.S : Queue kosong dengan alokasi Min 2 dan Maks 4 */
/* F.S : Menghasilkan Q yang berisi informasi seluruh pemain berupa nama dengan skor awal = 0 */
{
	int i;
	Pemain P;
	CreateEmpty(&(*Q),Maks);
	for (i = 1; i <= MaxEl(*Q); i++)
	{
		printf("Nama Pemain %d :  ", i);
		scanf("%s", &P.Nama);
		P.Skor = 0;
		Add(&(*Q),P);
	}
}
示例#8
0
IEffect* EffectFactory::CreateSinglePass(const FileIdRef& fileId,IRenderPass* renderPass,ResourceShareType shareType /*= ResourceShareType::Share*/)
{
	IEffect* effect = nullptr;
	if (shareType != ResourceShareType::None)
	{
		effect = Find(fileId);
		RETURN_SELF_IF_NOT_NULL(effect);
	}

	effect= CreateEmpty(fileId,shareType);
	RETURN_NULL_IF_NULL(effect);

	effect->GetGroupByIndex(0)->GetTechniqueByIndex(0)->AddPass(renderPass);
	return effect;
}
示例#9
0
	bool Texture::Load(const void* wrapper)
	{
		std::string str;

		if (!IsObject(wrapper)) return false;

		if (!LoadMemberValue(wrapper, "format", str))
		{
			FURYE << "Texture param 'format' not found!";
			return false;
		}
		auto format = EnumUtil::TextureFormatFromString(str);
		
		if (!LoadMemberValue(wrapper, "type", str))
			str = EnumUtil::TextureTypeToString(TextureType::TEXTURE_2D);
		auto type = EnumUtil::TextureTypeFromString(str);

		int width, height;
		if (!LoadMemberValue(wrapper, "width", width) || !LoadMemberValue(wrapper, "height", height))
		{
			FURYE << "Texture param 'width/height' not found!";
			return false;
		}
		
		auto filterMode = FilterMode::LINEAR;
		if (LoadMemberValue(wrapper, "filter", str))
			filterMode = EnumUtil::FilterModeFromString(str);

		auto wrapMode = WrapMode::REPEAT;
		if (LoadMemberValue(wrapper, "wrap", str))
			wrapMode = EnumUtil::WrapModeFromString(str);

		auto color = Color::Black;
		LoadMemberValue(wrapper, "borderColor", color);
		SetBorderColor(color);

		bool mipmap = false;
		LoadMemberValue(wrapper, "mipmap", mipmap);

		SetFilterMode(filterMode);
		SetWrapMode(wrapMode);

		CreateEmpty(width, height, format, type, mipmap);

		return true;
	}
示例#10
0
IEffect* EffectFactory::CreateMultiplePasses( const FileIdRef& fileId,List<IRenderPass*>& renderPasses ,ResourceShareType shareType /*= ResourceShareType::Share*/)
{
	IEffect* effect = nullptr;
	if (shareType != ResourceShareType::None)
	{
		effect = Find(fileId);
		RETURN_SELF_IF_NOT_NULL(effect);
	}


	effect= CreateEmpty(fileId,shareType);
	RETURN_NULL_IF_NULL(effect);
	EffectTechnique* technique=effect->GetGroupByIndex(0)->GetTechniqueByIndex(0);
	FOR_EACH_COLLECTION(i,renderPasses)
	{
		technique->AddPass(*i);
	}
示例#11
0
	Texture::Ptr Texture::Get(int width, int height, TextureFormat format, TextureType type)
	{
		std::stringstream ss;
		ss << width << "*" << height << "*" << EnumUtil::TextureFormatToString(format) << 
			"*" << EnumUtil::TextureTypeToString(type);
		std::string name = ss.str();

		auto match = EntityUtil::Instance()->Get<Texture>(name);
		if (match == nullptr)
		{
			match = Texture::Create(name);
			match->CreateEmpty(width, height, format, type);
			EntityUtil::Instance()->Add(match);
		}

		return match;
	}
示例#12
0
	void DataFileDB::Attach(const Data& init, const string& variablename,FileDBType type)
	{
		dir=savedir+"/"+variablename+"-db";
		dbtype=DatabaseExist();

		security.WriteFile(dir);

		if(dbtype!=DBNone)
		{
			Dump("DataFileDB::Attach(const Data&, const string&, FileDBType)","load old",init);
			LoadContent();
		}
		else
		{
			dbtype=type;
			Dump("DataFileDB::Attach(const Data&, const string&, FileDBType)","create new",init);
			CreateEmpty();
			DataFileDB::operator=(init);
			MarkAllDirty();
		}
	}
示例#13
0
market Del(Queue *Q)
{
	market take;
	take.harga_barang=-1;

	if(!isEmpty(*Q))
	{
		take=(*Q).happy[(*Q).Head];
		if(OneElement (*Q))
			CreateEmpty(&(*Q));
		else
		{
			if((*Q).Head==MAX-1)
				(*Q).Head=0;
			else
				(*Q).Head++;
		}
		return take;
	}
	return take;
}
示例#14
0
bazar Del(Queue *Q)
{
	bazar take;
	take.harga=-1;

	if(!isEmpty(*Q))
	{
		take=(*Q).hayati[(*Q).Head];
		if(OneElement (*Q))
			CreateEmpty(&(*Q));
		else
		{
			if((*Q).Head==MAX-1)
				(*Q).Head=0;
			else
				(*Q).Head++;
		}
		return take;
	}
	return take;
}
int main()
{
	int d;
	char pilihan;
	Stack S;

	CreateEmpty(&S);
	printf("%d %d\n",S.TOP,S.T[S.TOP]);
	PrintStack(S);
	while (!IsFull(S))
	{
		scanf("%c %d",&pilihan,&d);
		if (pilihan =='p')
			Pop(&S,d);
		else if (pilihan == 'h') 
			Push(&S,d);
		PrintStack(S); printf("%d\n",S.TOP);
	}	
		
	return 0;
}
示例#16
0
int main(){
/*kamus*/
  Stack S;
  address i;
  infotype x;
/*algoritma*/
  CreateEmpty(&S);
  
  /*mengisi nilai s*/
  printf("masukkan isi stack:\n");
  while(!IsFull(S)) {
  	scanf("%d",&x);
  	if(x==999) break;
  	Push(&S,x);
	}
  TulisStack(S);
  FilterStack(&S);
  printf("\nSetelah dibuang bilangan ganjil:\n");
  TulisStack(S);
	return 0;
}
示例#17
0
Model* ModelManager::LoadResource( const char *filename )
{
	if ( strstr( filename, ".obj" ) )
	{
		ModelStatic *mdl = new ModelStatic;
		mdl->LoadObj( filename );
		return mdl;
	} else
	if ( strstr( filename, ".atgi" ) )
	{
		ModelStatic *mdl = new ModelStatic;
		mdl->LoadAtgi( filename );
		return mdl;
	} else
	if ( strstr( filename, ".md5mesh" ) )
	{
		ModelJointed *mdl = new ModelJointed;
		mdl->LoadMd5Mesh( filename );
		return mdl;
	}
	return CreateEmpty( filename );
}
示例#18
0
文件: main.c 项目: heronimus/TF-UAJY
void main() {
//Deklarasi Antrian dan data penampung.
    Queue QFest,QTribun;
    Data NewVal;
    double TotalJumlah=0,TotalT=0,TotalF=0;
    int menu;

//Inisialisasi Antrian
    CreateEmpty(&QFest);
    CreateEmpty(&QTribun);

//showMenu
    do {
        system("CLS");
        printf("===== KONSER TONG TONG BAND =====\n");
        printf("1. Masukan Antrian \n");
        printf("2. Tampil Antrian Tribun \n");
        printf("3. Tampil Antrian Festival \n");
        printf("4. Transaksi Antrian Tribun \n");
        printf("5. Transaksi Antrian Festival \n");
        printf("6. Jumlah Pendapatan \n");
        printf("7. TUGAS - Jumlah Pendapatan \n");
        printf("================================= \n");
        printf(" >> Masukan Menu : ");
        scanf("%d",&menu);

        switch(menu) {
        case 1 ://Input Antrian
            printf(" Nama                         : ");
            fflush(stdin);
            gets(NewVal.nama);
            printf(" No Hp                        : ");
            fflush(stdin);
            gets(NewVal.no_hp);

            //Pemilihan Jenis Tiket
            while(strcmpi(NewVal.jenis_tiket,"festival")!=0 && strcmpi(NewVal.jenis_tiket,"tribun")!=0) {
                printf(" Jenis Tiket(festival/tribun) : ");
                fflush(stdin);
                gets(NewVal.jenis_tiket);
            }
            if(strcmpi(NewVal.jenis_tiket,"festival")==0) {
                //Cek AntrianFestival
                if (isFull(QFest)) {
                    printf("\n antrian penuh . . .");
                    strcpy(NewVal.jenis_tiket,"-");
                    break;
                }
                //Auto Tiket
                NewVal.no_antrian=AutoID(&QFest);
                printf(" Nomor Tiket                  : %d \n",NewVal.no_antrian);
                //Prosesur Add
                Add(&QFest,NewVal);

            }
            if(strcmpi(NewVal.jenis_tiket,"tribun")==0) {

                //Cek AntrianTribun
                if (isFull(QTribun)) {
                    printf("\n antrian penuh . . .");
                    strcpy(NewVal.jenis_tiket,"-");
                    break;
                }
                //Auto Tiket
                NewVal.no_antrian=AutoID(&QTribun);
                printf(" Nomor Tiket                  : %d \n",NewVal.no_antrian);
                //Prosesur Add
                Add(&QTribun,NewVal);
            }


            //Reset Jenis Tiket
            strcpy(NewVal.jenis_tiket,"-");
            break;
        case 2 :
            //Cek Antrian Kosong
            if (isEmpty(&QTribun)) {
                printf("\n antrian kosong . . .");
                break;
            }
            //Prosedur Show
            ShowQueue(QTribun);
            break;
        case 3 :
            //Cek Antrian Kosong
            if (isEmpty(&QFest)) {
                printf("\n antrian kosong . . .");
                break;
            }
            //Prosedur Show
            ShowQueue(QFest);
            break;
        case 4 :
            if (isEmpty(&QTribun)) {
                printf("\n antrian kosong . . .");
                break;
            }
            //Print Transaksi
            printf("\n ====== Transaksi Tribun====== \n");
            JumlahPendapatan(QTribun,&TotalJumlah,&TotalT,&TotalF);
            Delete(&QTribun);


            break;
        case 5 :
            if (isEmpty(&QFest)) {
                printf("\n antrian kosong . . .");
                break;
            }
            //Print Transaksi
            printf("\n ====== Transaksi Festival====== \n");
            JumlahPendapatan(QFest,&TotalJumlah,&TotalT,&TotalF);
            Delete(&QFest);

            break;
        case 6 :
            printf("\n Total Pendapatan          = %lf",TotalJumlah);
            break;
        case 7 :
            printf("\n Total Pendapatan Tribun   = %lf",TotalT);
            printf("\n Total Pendapatan Festival = %lf",TotalF);
            printf("\n---------------------------------------- ++");
            printf("\n Total Pendapatan          = %lf",TotalT+TotalF);
            break;
        case 8 :
            printf(" Head %d \n",QTribun.head);
            printf(" Tail %d \n",QTribun.tail);


        }
        getch();
    } while(menu!=0);

}
示例#19
0
	Testing(Data *data)                         { ptr = CreateEmpty(data); }
示例#20
0
int main()
{
	/*kamus*/
	Queue Q;
	int n,n2,i;
	int t = 0; // waktu masukan
	int pret = 0; // waktu sebelum t. cek pret<=t
	int tclose; // waktu tutup
	int visitor = 0;
	float srvtime = 0; // total waktu pelayanan
	float que = 0; // total antrian*waktu
	char input[6];
	boolean close;
	/*algoritma*/
	printf("Ukuran Queue : ");
	scanf("%d",&n);
	CreateEmpty(&Q,n);
	close = false;
	do {
		printf("Masukkan perintah: ");
		scanf("%d%s",&t,input);
		if(t<pret) printf("Waktu yang dimasukkan tidak valid, seharusnya >= %d\n",pret);
		else {
			switch(input[0]) {
				case 'a' : 
							if(IsFull(Q)) printf("Queue penuh, tidak bisa menerima pengunjung baru\n");
							else {
								que+=NBElmt(Q)*(t-pret);
								Add(&Q,t);
								printf("Q = ");
								PrintQueue(Q);
							}
							break;
				case 'c' :
							close = true;
							tclose = t;
							if (IsEmpty(Q)) 
								printf("Bank tutup, tidak ada pengunjung tersisa\n");
							else printf("Bank tutup, masih ada %d pengunjung tersisa\n",NBElmt(Q));
							break;
				case 'd' :
							if(IsEmpty(Q))
								printf("Queue kosong, tidak ada pengunjung yang akan dilayani\n");
							else {
								visitor++;
								Del(&Q,&n);
								if(!close) que+=NBElmt(Q)*(t-pret);
								printf("waktu kedatangan = %d, waktu tunggu = %d, Q = ",n,t-n);
								PrintQueue(Q);
								srvtime += t-n;
							}
			}
			pret=t;
		}
	}while(!close || !IsEmpty(Q));

	printf("\nBank tutup pada t = %d, layanan selesai pada t = %d\n",tclose,t);
	if(visitor) {
		printf("Jumlah pengunjung dilayani: %d orang\n",visitor);
		printf("Waktu tunggu rata-rata: %.0f satuan waktu\n",srvtime/visitor);
		printf("Panjang antrian rata-rata: %.3f orang\n",que/tclose);
	} else printf("Tidak ada pengunjung yang dilayani\n");
	
	return 0;	
}
示例#21
0
void StartGame(ArrayofPlayer *T)
{
	String opt,pesan,Card,nama;
	char c;
	Dataplayer Player;
	Deck D;
	Kartu C;
	int i,j,id,x,y,stat,g,ids,tmp,Rockfall_Counter;
	boolean End,alert,Sudah_Ambil,Keluar_Kartu,help;
	i = 0;
	AcakKarakterPlayer(T);
	End = false;
	alert = false;
	Sudah_Ambil = false;
	Keluar_Kartu = false;
	Rockfall_Counter = 2;
	help = false;
	CreateEmpty(&D);
	DefaultDeck(&D);
	ShuffleDeck(&D);
	DeckReady(&D);
	BagiKartu(T,&D);
	Board_Init(5,5);
	do {
		clrscr();
		canvas();
		if (help){
			GameHelp();
			help = false;
			clrscr();
			canvas();
		}
		Board_Print();
		id = i % NbPlayer(*T);
		Player = NamePlayer(*T,id);
		ShowKartuPlayer ((*T).Player[id]);
		DrawPile(!IsEmpty(D));
		ShowPlayerList(*T);
		if (IsEmpty(D)){
			Sudah_Ambil = true;
		}
		if (alert){
			gotoxy(5,35);
			printf("%s",pesan);
			alert = false;
		}
		x = 114;
		y = 1;
		for (j=0;j<27;j++){
			gotoxy(x+j,y);
			printf("=");
			gotoxy(x+j,y+3);
			printf("_");
			gotoxy(x+j,y+35);
			printf("=");
		}
		x = 139;
		y = 2;
		for (j=0;j<34;j++){
			gotoxy(x,y+j);
			printf("||");
		}
		gotoxy(5,34);
		printf("%s >> ",Player.Name);
		EmptyStr(opt);
		scanf("%s",opt);
		if (StrEq(opt,"putonboard")){
			do {
				scanf("%c",&c);
			} while(c == ' ');
			EmptyStr(Card);
			if (c != '\n'){
				scanf("%[^\"]s",Card);
				scanf("%c",&c);
			}
			scanf("%d %d",&x,&y);
			scanf("%d",&stat);
			if ((*T).Player[id].Condition == Disabled){
				alert = true;
				EmptyStr(pesan);
				CopyStr("Anda dalam kondisi Disabled",pesan);
			}else if (Keluar_Kartu){
					alert = true;
					EmptyStr(pesan);
					CopyStr("Anda sudah mengeluarkan kartu",pesan);
			}else{
				if (TakeKartufromPlayer(T,id,Card,&C)){
					if (C.ID <= 16){
						if (stat == 180){
							g = (((C.Guna>>2)&3)+((C.Guna&3)<<2) & 15) + (C.Guna & 16);
						}else{
							g = C.Guna;
						}
						tmp=Board_CekPut(x-1,y-1,g);
						if (tmp>0){
							Board_PutCard(x-1,y-1,g);
							if ((Board_Win==-1)&&(Rockfall_Counter)){
								Board_Win=0;
							}
							Keluar_Kartu = true;
						}else{
							FillKartuonPlayer(T,id,C);
							alert = true;
							EmptyStr(pesan);
							switch(tmp){
								case 0: CopyStr("Koordinat di luar papan permainan",pesan);
										break;
								case -1:CopyStr("Posisi target sudah ada kartu lain",pesan);
										break;
								case -2:CopyStr("Kartu tidak terhubung dengan kartu Start",pesan);
										break;
								case -3:CopyStr("Bentuk kartu salah",pesan);
										break;
							}
							//CopyStr("Posisi atau kartu path tidak valid",pesan);
						}
					}else{
						FillKartuonPlayer(T,id,C);
						alert = true;
						EmptyStr(pesan);
						CopyStr("Bukan kartu path",pesan);
					}
				}else{
					alert = true;
					EmptyStr(pesan);
					CopyStr("Kartu tidak ada",pesan);
				}
			}
示例#22
0
文件: main.c 项目: ADTers/Wordament
int main()
{
	LoadDict(&M);
    	system("clear");
    	printf("%s=====================================================================\n", cyan);
    	printf(" _       ______  ____  ____  ___    __  __________   ________   ____ \n");
    	printf("| |     / / __ \\/ __ \\/ __ \\/   |  /  |/  / ____/ | / /_  __/  / __ \\ \n");
    	printf("| | /| / / / / / /_/ / / / / /| | / /|_/ / __/ /  |/ / / /    / / / /\n");
    	printf("| |/ |/ / /_/ / _ _ / /_/ / ___ |/ /  / / /___/ /|  / / /    / /_/ / \n");
    	printf("|__/|__/\\____/_/ |_/_____/_/  |_/_/  /_/_____/_/ |_/ /_/     \\____/  \n\n");
    	printf("=====================================================================\n\n\n");
    	printf("                      %sPress any key to continue%s\n",magenta,normal);
    	getch();
   	while(opt1 != 5)  //OPT1 = 5 adalah QUIT
	{
        MainMenu(&opt1);       // MENAMPILKAN MAIN MENU
        switch(opt1)
        {
            case 1 : 	// REGISTER
                printf("%sEnter user name : ", cyan);

                do
                {
                    found = false;	// INISIALISASI YANG MENANDAKAN USER BELUM DITEMUKAN DI FILE EKSTERNAL
                    scanf("%s", username.TabKata);
                    username.Length = strlen(username.TabKata); 
                    if(strlen(username.TabKata) >= 20 || !(IsAlNumS(username))) // MENGECEK APAKAH LEBIH DARI 20 ATAU ALFANUMERIK
                        printf("Username must be alphanumeric / less or equal to 20 characters\n");
                    else
                    {
                        *x = "scores/List Users & Highscores 2.txt";
                        STARTKATA();
                        while(!EndKata && !found)
                            CheckUser(username,&id,&found);

                        if(found)
                            printf("Sorry, that username already exists\n");
                    }
                }while((strlen(username.TabKata) >= 20 || !(IsAlNumS(username))) || found);
		
                SalinFile(LU,username);
                printf("Congratulations! %s has been successfully registered\n",username.TabKata);
                printf("\n");
                printf("%sPress any key to continue%s\n", magenta,cyan);
                dummygetch = getch();
		dummygetch = getch();
                break;

            case 2 :	//LOGIN			
                CreateList(&LU);
                printf("\n");
                *x = "scores/List Users & Highscores 2.txt";
                STARTKATA();
                while(!(EndKata))
                    InitUser(&LU,&id);	// MEMASUKKAN DATA FILE EKSTERNAL KE DALAM LIST
                InversListU(&LU);
                ListUsersLengkap(LU);	// MENAMPILKAN LIST USER
                found1 = false;		// INISIALISASI YANG MENANDAKAN USERNAME TIDAK DITEMUKAN
                while(!found1)
                {
                    printf("=====================================================================\n");
                    printf("Enter username : "******"%s",username1.TabKata);
                    username1.Length = strlen(username1.TabKata);
                    STARTKATA();
                    while(!EndKata && !found1)
                        CheckUser(username1,&id,&found1);

                    if(!found1)
                        printf("%s not found. Try again\n",username1.TabKata);
                }

                SelectB = true;	// INISIALISASI AGAR SETELAH MEMILIH BOARD, MELIHAT SCORE TIDAK KELUAR KE MAIN MENU, MELAINKAN PREP MENU
                selectT = false;	// INISIALISASI YANG MENANDAKAN USER BELUM PILIH BOARD
                
                while(SelectB == true)
                {
		    if(selectT == false)
			kode = 1;

                    PrepMenu(&opt2, username1);	// PREPARATION MENU
                    switch(opt2)
                    {
                        case 1 :	// PLAY GAME
                            if(selectT == false) 
			    {
                                kode = 1;
                                *y = "boards/1.txt";
                            }
                            baris = 1;
                            kolom = 1;
                            T = false;
                            used = false;
                            score = 0;
                            CreateEmptyQ(&QFinish);
                            CreateEmpty(&S);
							CreateListSU(&LSG);
							CreateListSU(&LSGTemp);
							
							ReadSuggestion(&LSG, kode);
							strcpy(tempsugg, username1.TabKata);
							PSU = FirstSU(LSG);
							usersuggfound = false;
							while (PSU != Nil) {
								if (strcmp(InfoSU(PSU), tempsugg) == 0) {
									usersuggfound =  true;
									break;
								}
								else {
									PSU = NextSU(PSU);
								}
							}
							if (!usersuggfound) {
								InsVSUFirst(&LSG, tempsugg);
								PSU = FirstSU(LSG);
							}
							InsVSUFirst(&LSGTemp, tempsugg);
							PSE = FirstSE(PSU);
							if (PSE != Nil) 
								strcpy(tempsugg, InfoSE(PSE));
							else {
								tempsugg[0] = ' ';
								tempsugg[1] = '\0';
							}
							CreateListSet(&LS);
                            CreateBoard(&B);
                            AmbilBoard(&B);
                            InitKursor(&B);
                            InitSelect(&B, &S);
                            system("clear");
                            printf("Score = %d\n\n", score);
                            printf("Suggestion = %s\n\n", InfoSE(PSE));
                            TulisBoard(B);
                            printf("\n\n");
                            dummygetch = getch();
                            input = getch();
                            printf("\n");
                            while (input != 'm')
                            {
                                system("clear");
                                ProsesKursor(&B, &baris, &kolom, &T, input, &error);
                                Select(&B, baris, kolom, T, &S, &score, &LS, &QFinish, &used, &LSG, &LSGTemp, &M, PSU);
                                printf("Score = %d\n\n", score);
                                PSE = FirstSE(PSU);
                                printf("Suggestion = %s\n\n", InfoSE(PSE));
                                TulisBoard(B);
                                printf("\n");
                                if (used)
									printf("Invalid Word\n");
								else
									printf("\n");
                                if (error)
                                    printf("error\n");
                                else
                                    printf("\n");
                                input = getch();
                                printf("\n");
                                error = false;
                                used = false;
                            }
                            time(&rawtime);	//INISIALISASI WAKTU
			    t = localtime(&rawtime);
			    D.YY = (*t).tm_year+1900;
			    D.MM = (*t).tm_mon+1;
			    D.DD = (*t).tm_mday;
		            J.HH = (*t).tm_hour;
		  	    J.MM = (*t).tm_min;
			    J.SS = (*t).tm_sec;
                            InsSortScoreU (&LU,D,J,score,username1);	//INSERT SCORE KE LIST SCORE
                            SalinInto(LU, kode);	// MENYALIN KE FILE EKSTERNAL
                            SelectB = false;
                            system("clear");
                            addressQ PQ;
                            PQ = Head(QFinish);
                            while (PQ != Nil) 
			    {
			    	PrintSet(InfoQ(PQ));
				printf("\n");
				PQ = NextQ(PQ);
		       	    }
				printf("Total Score = %d\n", score);
							PSU = FirstSU(LSG);
							PSE = FirstSE(PSU);
							PSUT = FirstSU(LSGTemp);
							while (PSUT != Nil) {
								PSET = FirstSE(PSUT);
								while (PSET != Nil) {
									InsVSEFirst(&LSG, PSU, InfoSE(PSET));
									PSET = NextSE(PSET);
								}
								PSUT = NextSU(PSUT);
							}
							WriteSuggestion(LSG, kode);
							printf("Press any key to continue\n");
							dummygetch = getch();
			    getch();
                            break;

                        case 2 :	//SELECT BOARD
                            PilihBoard(&selectT, &kode);
		            CreateList(&LU);
			    STARTKATA();
                            while(!(EndKata))
                    	       InitUser(&LU,&id);	// MEMASUKKAN DATA FILE EKSTERNAL KE DALAM LIST
                	    InversListU(&LU);
                            SelectB = true;
                            break;

                        case 3 :	//VIEW MY HIGH SCORES
			    ViewMyHighScores(LU,username1);
			    printf("%sPress any key to continue%s\n", magenta,cyan);
			    dummygetch = getch();
			    dummygetch = getch();
                            SelectB = true;
  			    break;

                        case 4 :	//VIEW ALL HIGH SCORES	
			    ViewAllHighScores(LU);
	              	    printf("%sPress any key to continue%s\n", magenta,cyan);
			    dummygetch = getch();
			    dummygetch = getch();
                            SelectB = true;
                            break;

                        case 5 :	//VIEW BOARD STATISTICS	
 				CreateEmptyQS(&QS);
                            	countuser = 0;
				countscore = 0;
				sumscore = 0;
				PU = FirstU(LU);
				while (PU != Nil)
				{
					PS = FirstS(PU);
					if((InfoD(PS)).YY != 0)
					{
						countuser += 1;
					}	
					while(PS != Nil)
					{
						if((InfoD(PS)).YY != 0)
						{
							countscore += 1;
							sumscore += InfoS(PS);
						}	
						PS = NextS(PS);	
					}
					PU = NextU(PU); 	
				}
				//CreateList(&LU);
				averagescore = sumscore/countscore;
				printf("%.0f user/s have played in board %d\n",countuser,kode);
				if(countscore == 0)
					averagescore = 0;
				printf("The average score in board %d is %.2f\n",kode,averagescore);
				AddQS(&QS,kode,averagescore);
				for(i=0; i<=9;i++)
				{
					switch(i)
					{
						case 0 : *x = "scores/List Users & Highscores 1.txt"; break;
						case 1 : *x = "scores/List Users & Highscores 2.txt"; break;
						case 2 : *x = "scores/List Users & Highscores 3.txt"; break;
						case 3 : *x = "scores/List Users & Highscores 4.txt"; break;
						case 4 : *x = "scores/List Users & Highscores 5.txt"; break;
						case 5 : *x = "scores/List Users & Highscores 6.txt"; break;
						case 6 : *x = "scores/List Users & Highscores 7.txt"; break;
						case 7 : *x = "scores/List Users & Highscores 8.txt"; break;
						case 8 : *x = "scores/List Users & Highscores 9.txt"; break;
						case 9 : *x = "scores/List Users & Highscores 10.txt"; break;
					}
					if(i != kode)
					{
						CreateList(&LP);
						STARTKATA();
						while(!EndKata)
							InitUser(&LP,&id);
					
						InversListU(&LP);
						sumscore = 0;
						countscore = 0;
						PX = FirstU(LP);
						while (PX != Nil)
						{
							PZ = FirstS(PX);	
							while(PZ != Nil)
							{
								if((InfoD(PZ)).YY != 0)
								{
									countscore += 1;
									sumscore += InfoS(PZ);
								}	
								PZ = NextS(PZ);	
							}
							PX = NextU(PX); 	
						}
						if (countscore == 0)
							averagescore = 0;
						else
							averagescore = sumscore/countscore;
						AddQS(&QS, i, averagescore);
					}
							
				}
				PX = FirstU(LP);
				DealokasiU(&PX);
				PZ = FirstS(PX);
				DealokasiS(&PZ);
				P = Head(QS);
				printf("Difficulty Level of Boards : \n");
				for(i=1;i<=10;i++)
				{						
					printf("%d. Board no.%d with average user scores of %.2f\n",i,InfoQ(P),Prio(P));
					P = NextQ(P);
					if (P == Nil)
					{
						break;
					}
				}
			    printf("%sPress any key to continue%s\n", magenta,cyan);
           		    dummygetch = getch();
		  	    dummygetch = getch();
			    SelectB = true;
			    break;

                        case 6 :	// LOG OUT
                            SelectB = false;
                            break;
                    }
                if(SelectB == false)
                    break;
                }
		break;
            case 3 :	// HOW TO PLAY
		HowToPlay();
                break;
            case 4 :	// ABOUT
                About();
                break;
        }
	}
	printf("%s\n", normal); //MENGGANTI WARNA TEXT TERMINAL KE AWAL
	
	return 0;
}