Beispiel #1
0
int main(){
int n;
printf("\nEnter the number of strings you want to add: ");
scanf("%d",&n);
int i;
char data[100];
TNode* root=NULL;
for(i=0;i<n;i++){
//printf("\nEnter the length of string you want to add : ");
printf("\nEnter the string you want to add : ");
scanf("%s",data);
InsertTrie(&root,data);
}
printf("\%d words added ",n);
getch();

printf("\nEnter the string you want to search : ");
scanf("%s",data);
int result=SearchTrie(root,data);
if(result){
printf("\nWord found !Hurray!");
}else{
printf("\nSorry! word not found !");
}
char* buffer=(char*)malloc(sizeof(char)*100);
printf("\nPress enter to print all the words in the dictionary you just created :\n");
getch();
PrintAll(root,buffer,0);
getch();
return 0;
}
Beispiel #2
0
void RunNewSystem()
{
	SYSTEMTIME t;
	GetLocalTime(&t);
	for (int i = 0; i < NewSystem_Enable.size(); i++)
	{
		if (NewSystem_Enable[i])
		{//тобто повідомлення вже було написано
			NewSystem_Iteration[i]++;
			if (NewSystem_Iteration[i] > 30)
			{
				NewSystem_Iteration[i] = 0;
				NewSystem_Enable[i] = false;
			}
		}
		else
		{
			SYSTEMTIME MsgTime = {0};
			MsgTime.wDay = NewSystem_Day[i] == -1? t.wDay : NewSystem_Day[i];
			MsgTime.wDayOfWeek = NewSystem_DayOfWeek[i] == -1? t.wDayOfWeek : NewSystem_DayOfWeek[i];
			MsgTime.wHour = NewSystem_Hour[i] == -1? t.wHour : NewSystem_Hour[i];
			MsgTime.wMinute = NewSystem_Min[i] == -1? t.wMinute : NewSystem_Min[i];
			MsgTime.wMonth = NewSystem_Month[i] == -1? t.wMonth : NewSystem_Month[i];

			if ( NewsDataEcval(t,MsgTime) == 0)
			{
				PrintAll(NewSystem_Type[i],(char*)NewSystem_Msg[i].c_str());
				NewSystem_Iteration[i] = 0;
				NewSystem_Enable[i] = true;
			}
		}
	}
}
Beispiel #3
0
void PrintLast(int x, FILE *pf_out)
{
    int nr=0;
    NODE *CurrNODE=head;
    while(CurrNODE!=NULL)
    {
        nr++;
        CurrNODE=CurrNODE->next;
    }
    if(x>=nr)
    {
        PrintAll(pf_out);
    }
    else
    {
        CurrNODE=tail;
        while(x>=1)
        {
            x-=1;
            CurrNODE=CurrNODE->prev;
        }
        while(CurrNODE!=NULL)
        {
            fprintf(pf_out,"%d ",CurrNODE->data);
            CurrNODE=CurrNODE->next;
        }
    }
    fprintf(pf_out, "\n");
}
Beispiel #4
0
void main()
{
	int nMenu = 0;
	LoadList(DATA_FILE_NAME);

	// 메인 이벤트 반복문
	while ((nMenu = PrintUI()) != 0) {
		switch (nMenu)	{
		case 1:		  // Add
			Add();
			break;

		case 2:		  // Search
			Search();
			break;

		case 3:		 // Print all
			PrintAll();
			break;

		case 4:		  // Remove
			Remove();
			break;
		}
	}

	// 종료 전에 파일로 저장하고 메모리를 해제한다.
	SaveList(DATA_FILE_NAME);
	ReleaseList();
}
Beispiel #5
0
void runDistances(BedFile1& refFile, BedFile2& nonRefFile, const Input& input) {
  bool printDistances = input.PrintDistances();
  bool suppressRefField = input.SuppressReference();
  if ( input.ShortestOnly() )
    findDistances(refFile, nonRefFile, input.AllowOverlaps(), PrintShortest(input.Delimiter(), printDistances, suppressRefField));
  else
    findDistances(refFile, nonRefFile, input.AllowOverlaps(), PrintAll(input.Delimiter(), printDistances, suppressRefField));
}
Beispiel #6
0
int main(int argc, char* argv[])
{
    Node* head = new Node(3);

    AddNode(&head, 5);
    AddNode(&head, 5);
    AddNode(&head, 5);
    AddNode(&head, 5);
    AddNode(&head, 8);

    PrintAll(head);

    RemoveDuplicate2(head);

    PrintAll(head);

    return 0;
}
int main()
{
  head = BuildOneTwoThree(head);

  PrintAll(head);

  printf("Lenght of the list is %d\n", Length(head));

  // insert 6
  Append(6, head);

  PrintAll(head);

  // insert 5

  // delete the whole list


}
Beispiel #8
0
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//
void Next()
{
  GetProjection(event, event);
  
  FindEdges(); 

  if( (start[1]-start[0])> MinStartDist ) // limit the burst distance
    {
      GetAmpSignals();
      
      GetPMTSignals();
      
      GetShpSignals();

      if( !(event%100) )
	{
	  DrawAll();  
	  DrawDistributions();
	  PrintAll();
	  printf("event: %i\n", event);
	}  
    }
  event++;

  if( event == event_lastt )
    {
      ftimer.Stop();
                  
      FitProfiles();
      
      PrintAll();

      DrawAll();  

      DrawDistributions();

      WriteAll();
      
      gSystem->Exit(1);
    }
}
Beispiel #9
0
void PrintAll(Unit unit[], int i)
{
	printf("\n Name : %s\n", unit[i].name);
	printf("   Hp : %.2lf\n", unit[i].hp);
	printf("   Mp : %.2lf\n", unit[i].mp);
	printf("Speed : %d\n", unit[i].speed);
	printf("Range : %d\n", unit[i].range);
	printf("Posit : %s\n", unit[i].position);
	if (i == SIZE - 1)
		return;
	PrintAll(unit, i + 1);
}
Beispiel #10
0
int Move(int *source, int *dest)
{
	int i,j;

	while (i<N && (source[i])==0) i++;
	while (j<N && (dest[j])==0) j++;

	dest[j-1] = source[i];
	source[i] = 0;
	PrintAll();       /* Print configuration after each move. */
	return dest[j-1];
}
//void MoveMemberData();
//Delete Index change need to use address &iIndex
void Delete_me(BAN MemberArray[],int * piIndex)//Delete func to delete member
{
	for(int i=0;i<*piIndex;i++){
		int iSearch = Search_name(MemberArray,piIndex);
		if(iSearch != -1){
			//PrintMemberData(&MemberArray[i]);
			DeleteAt(MemberArray,piIndex,iSearch);
		}else
		{
			printf("NOT FOUND!!!");
		}
	}
	PrintAll(MemberArray,*piIndex);
}
Beispiel #12
0
int main()
{
    FILE *f1=fopen("input.dat","r");
    FILE *f2=fopen("output.dat","w");
    char s[15];
    int data;
    p->head=0;
    p->tail=0;

    while(fscanf(f1, "%s", s)==1)
    {
        if(strcmp(s, "AF")==0)
        {
            fscanf(f1, " %d", &data);
            AddFirst(data);
        }
        if(strcmp(s, "AL")==0)
        {
            fscanf(f1, " %d", &data);
            AddLast(data);
        }
        if(strcmp(s, "DF")==0)
            DeleteFirst();
        if(strcmp(s, "DL")==0)
            DeleteLast();
        if(strcmp(s, "DE")==0)
        {
            fscanf(f1, "%d", &data);
            DeleteElem(data);
        }
        if(strcmp(s, "DOOM_THE_LIST")==0)
            Doom_The_List();
        if(strcmp(s, "PRINT_ALL")==0)
            PrintAll(f2);
        if(strcmp(s, "PRINT_F")==0)
        {
            fscanf(f1, "%d", &data);
            PrintFirst(data, f2);
        }
        if (strcmp(s,"PRINT_L")==0)
        {
            fscanf(f1, "%d", &data);
            PrintLast(p->tail, data, f2);
            fprintf(f2, "\n");
        }
    }

    return 0;
}
Beispiel #13
0
int main()
{
    FILE *pf_in=fopen("input.dat", "r");
    FILE *pf_out=fopen("output.dat", "w");
    char action[20];
    int value;
    while(fscanf(pf_in,"%s %d", &action, &value)!=EOF)
    {
        if((strcmp(action,"AF"))==0)
        {
            AddFirst(value);
        }
        if((strcmp(action,"AL"))==0)
        {
            AddLast(value);
        }
        if((strcmp(action,"DF"))==0)
        {
            DelFirst();
        }
        if((strcmp(action,"DL"))==0)
        {
            DelLast();
        }
        if((strcmp(action,"DOOM_THE_LIST"))==0)
        {
            DoomList();
        }
        if((strcmp(action,"DE"))==0)
        {
            DeleteCertainElement(value);
        }
        if((strcmp(action,"PRINT_ALL"))==0)
        {
            PrintAll(pf_out);
        }
        if((strcmp(action,"PRINT_F"))==0)
        {
            PrintFirst(value, pf_out);
        }
        if((strcmp(action,"PRINT_L"))==0)
        {
            PrintLast(value, pf_out);
        }
    }
    fclose(pf_in);

    return 0;
}
Beispiel #14
0
int main()
{
	Date compGradDate(12, 6, 2017);

	MathStudent numberStudent("Jeremy Lin", 12456717, 25, "617-823-8925",
							  'M', "Freshman", 3.0, "42 Harwood Avenue",
							  "Harwich", "MA.", 82653);

	CS1Cstudent compStudent("James Davis", 98035769, 25, "661-877-8825",
							'M', "Sophomore", 3.5, 120, true, compGradDate);

	Student		student("Douglas Adams", 42424242, 42, "666-987-0042",
						'M', "Senior", 4.2);

	cout << endl << endl;
	PrintAll(numberStudent);
	cout << endl << endl;
	PrintAll(compStudent);
	cout << endl << endl;
	PrintAll(student);
	cout << endl << endl;

	return 0;
}
int main(){
	int n;
	//head = NULL;
	gets(str);
	scanf("%d",&n);
	Create(str);
	for(int i = 0; i < n; i++){
		int k;
		char c;
		scanf("%d ",&k);
		c = getchar();
		Insert(c,k);
		Delete(k);
		PrintAll(i == n - 1?1:0);
	}
	return 0;
}
//sap xep theo shellsort
void sort_by_shell(BAN ban[],int size)
{
	int i,j,interrup;
	BAN temp;
	for(interrup=size/2;interrup>0;interrup=interrup/2){
		for(i=0;i<size;i=i+interrup){
			temp=ban[i];
			//strcpy(temp.numberphone,ban[i].numberphone);
			for(j=i;j>0 && compare_string(ban[j-interrup].numberphone,ban[j].numberphone)==1;j--){
				//strcpy(ban[j].numberphone,ban[j-interrup].numberphone);
				ban[j] = ban[j-interrup];
			}
			ban[j] = temp;
			//strcpy(ban[j].numberphone,temp.numberphone);
		}
	}
	PrintAll(ban,size);
}
int main(int argc, char *argv[]) {
  if (argc != 3) {
    fprintf(stderr, "usage: %s input.index digits\n", argv[0]);
    return 2;
  }

  FILE *fp = fopen(argv[1], "rb");
  if (fp == NULL) {
    fprintf(stderr, "error: can't open \"%s\"\n", argv[1]);
    return 1;
  }

  IndexReader reader(fp);
  PhoneFilter filter(argv[2]);
  SearchDriver driver(&reader, &filter, 0, 1e-6);
  PrintAll(&driver);
  return 0;
}
Beispiel #18
0
void PrintAll(TNode* root,char* buffer,int index){
if(!root){
return;
}
int i;

if(root->data==1){
PrintCurrent(buffer,index);
}


for(i=0;i<26;i++){
if(root->next[i]){
buffer[index]=97+i;
PrintAll(root->next[i],buffer,index+1);
}
}
}
Beispiel #19
0
int
main()
{
	int i;

	/* initialize the towers */
	for(i=0;i<N;i++)A[i]=i+1;
	for(i=0;i<N;i++)B[i]=0;
	for(i=0;i<N;i++)C[i]=0;

	printf("Solution of Tower of Hanoi Problem with %d Disks\n\n",N);

	/* Print the starting state */
	printf("Starting state:\n");
	PrintAll();
	printf("\n\nSubsequent states:\n\n");

	/* Do it! Use A = Source, B = Destination, C = Spare */
	Hanoi(N,A,B,C);
	return 0;
}
Beispiel #20
0
void Play(tGame * game)
{	
	int legal;

	tScan scan;
	tCommand command;
	command.undo.can_undo = FALSE;
	command.undo.undo_error = FALSE;
	command.undo.lastboard.rows = game->visualboard.rows; 
	command.undo.lastboard.columns = game->visualboard.columns;
	CreateBoard(&command.undo.lastboard);;

	do
	{
		PrintAll(game, &command);
		
		do
		{	
			if ((legal = InputCommand(&scan)))
			{	
				if((legal = LegalCommand(&scan, &command)))
					if (command.command_ref < 5) /*All commands but quit or undo*/
						legal = LegalParams(game, &command, &scan);
			}

		if (!legal)
			printf("%s%s%s\n", KERR, COMMAND_ERR, KDEF);

		} while (!legal);

		ExecCommand(game, &command);
		CheckGameState(game);
	} while(game->gamestate == GAMESTATE_DEFAULT);

	PrintResult(game);

	freeBoard(game->hiddenboard.board, game->hiddenboard.rows);
	freeBoard(game->visualboard.board, game->hiddenboard.rows);
	return;
}
Beispiel #21
0
void main()
{
	BOOK BookArray[3];
	int iIndex =0;
	int iChoice = 1;
	while( iChoice !=0)
	{
		printf("\n1.Input\n");
		printf("2.Print All\n");
		printf("3.Search\n");
		scanf("%d", &iChoice);
		fflush(stdin);
		switch(iChoice)
		{
		case 1:
			InputBookMember(BookArray, &iIndex, sizeof(BookArray)/sizeof(BookArray[0]));
			break;
		case 2:
			PrintAll(BookArray,iIndex);
			break;
		}
	}
}
Beispiel #22
0
    void PrintInput() {
        PrintAll(init_share);
        PrintAll(TransferMat);

    }
Beispiel #23
0
 virtual void PrintResult(){
     PrintAll(nums);
 }
Beispiel #24
0
 void PrintResult() {
     PrintAll(eq_share);
 }
Beispiel #25
0
 virtual void PrintInput(){
     PrintAll(nums);
 }
Beispiel #26
0
int main()
{
	Unit unit[SIZE] = {
		{ "Lux", 477.72, 334, 330, 550, "mid" },
		{ "Ashe", 527.72, 231.8, 325, 600, "bot" },
		{ "Sona", 482.36, 340.6, 325, 550, "bot" },
		{ "Nocturn", 582.8, 273.8, 345, 125, "jungle" },
		{ "Amumu", 613.12, 287.2, 335, 125, "jungle" },
		{ "Veigar", 492.76, 342.4, 340, 525, "mid" },
		{ "Taric", 619.2, 349.08, 340, 125, "bot" },
		{ "Leesin", 570.8, 200, 350, 125, "jungle" },
		{ "Irelia", 607.2, 288.8, 345, 125, "top" },
		{ "Corki", 512.76, 305.16, 325, 550, "bot" },
		{ "Alistar", 513.36, 278.84, 330, 125, "bot" },
		{ "Tryndamere", 625.64, 100, 345, 125, "top" },
		{ "Fiddlesticks", 524.4, 350.12, 335, 480, "jungle" },
		{ "Vayne", 498.44, 231.8, 330, 550, "bot" },
		{ "Anivia", 467.6, 346.04, 325, 600, "mid" },
		{ "Morgana", 547.48, 340.8, 335, 450, "mid" },
		{ "Graves", 551.12, 322.2, 330, 525, "bot" },
		{ "Gangplank", 631.08, 282.2, 345, 125, "top" },
		{ "Ezreal", 484.4, 310.6, 325, 550, "bot" },
		{ "Singed", 542.76, 290.6, 345, 125, "top" }
	};
	Unit Utemp = { 0, };

	int sel = 0;
	char Search_name[20] = { 0, };
	char Delete_name[20] = { 0, };
	char Delete_pos[20] = { 0, };

	char Insert_name[20] = { 0, };
	char Insert_position[20] = { 0, };
	double Insert_hp = 0;
	double Insert_mp = 0;
	int Insert_speed = 0;
	int Insert_range = 0;

	int index = 0;

	while (1)
	{
		printf("\n(1)Search (2)Insert (3)Delete (4)DeleteAll (5)PrintAll (6)FindMaxHp (7)SortByHp\n Input : ");
		scanf_s("%d", &sel);

		switch (sel)
		{
		case 1://Search
			printf("Search input : ");
			scanf("%s", Search_name);

			Search(unit, Search_name, 0);

			break;
		case 2://Insert
			printf("Name input : ");
			scanf("%s", Insert_name);
			printf("Hp input : ");
			scanf("%lf", &Insert_hp);
			printf("Mp input : ");
			scanf("%lf", &Insert_mp);
			printf("Speed input : ");
			scanf("%d", &Insert_speed);
			printf("Range input : ");
			scanf("%d", &Insert_range);
			printf("Position input : ");
			scanf("%s", Insert_position);

			Insert(unit, Insert_name, Insert_hp, Insert_mp, Insert_speed, Insert_range, Insert_position, 0);
			break;
		case 3://Delete
			printf("Delete input : ");
			scanf("%s", Delete_name);

			Delete(unit, Delete_name, 0);
			break;
		case 4://DeleteAll
			printf("Position input : ");
			scanf("%s", Delete_pos);

			DeleteAll(unit, Delete_pos, 0);
			break;
		case 5://PrintAll
			PrintAll(unit, 0);
			break;
		case 6://FindMaxHp
			index = FindMaxHp(unit, 0, 0, 0);

			printf("\n Name : %s\n", unit[index].name);
			printf("    Hp : %.2lf\n", unit[index].hp);
			printf("    Mp : %.2lf\n", unit[index].mp);
			printf("Speed : %d\n", unit[index].speed);
			printf("Range : %d\n", unit[index].range);
			printf("  Pos : %s\n", unit[index].position);
			break;
		case 7://SortByhp
			SortByHp(unit, unit, Utemp, 0, 0);
			printf("\nSortByHp Complete!!\n\n");
			break;
		}
	}
	return 0;
}
int connectToSlave(modbus_t *ctx)
{
	uint16_t *tab_rp_registers; // for getting data from server( slave module )
	int i,j;                    // for repeat
	int nb_points;              // number of register
	int rc;                     // register counter

	char query[QUERY_SIZE];     // for getting query

	char sSlaveNum[3];
	char sFuncCode[3];
	char sRegiAdd[5];
	char sRegiNum[5];
	char sData[5];
	char svData[MODBUS_MAX_WRITE_REGISTERS][5];
	// MODBUS_MAX_WRITE_REGISTERS : set value in modbus.h
	char sWriteNum[3];                      // str for read data in query

	uint16_t nSlaveNum;
	uint16_t nFuncCode;
	uint16_t nRegiAdd;
	uint16_t nRegiNum;
	uint16_t nData;
	uint16_t nvData[MODBUS_MAX_WRITE_REGISTERS];
	uint8_t nWriteNum;                      // variable for read data in query

	/* Allocate and initialize the memory to store the registers */
	nb_points = (UT_REGISTERS_NB > UT_INPUT_REGISTERS_NB) ?
		UT_REGISTERS_NB : UT_INPUT_REGISTERS_NB;
	tab_rp_registers = (uint16_t *) malloc(nb_points * sizeof(uint16_t));
	memset(tab_rp_registers, 0, nb_points * sizeof(uint16_t));

	while ( 1 )
	{
		memset(sSlaveNum, 0, sizeof(sSlaveNum) );
		memset(sFuncCode, 0, sizeof(sFuncCode) );
		memset(sRegiAdd, 0, sizeof(sRegiAdd) );
		memset(sRegiNum, 0, sizeof(sRegiNum) );
		memset(sData, 0, sizeof(sData) );
		for ( i=0 ; i< MODBUS_MAX_WRITE_REGISTERS ; i++ )
			memset(svData[i], 0, sizeof(svData[i]) );
		memset(sWriteNum, 0, sizeof(sWriteNum) );
		memset(query, 0, QUERY_SIZE);
		// memory init

		printf("\tinput Query ( \"q\" exit, \"all\" show all data, \"r\" random query )\n");
		printf("\tQUERY : ");
		scanf( "%s", query );
		printf("\n");

		if ( !strcmp( query, "q" ) )    // quit message
			break;  // while break
		else if ( !strcmp( query, "all" ) )
		{
			PrintAll(ctx, tab_rp_registers, UT_REGISTERS_NB);      // print all data
			continue;
		}
		else if ( !strcmp( query, "r") )                // random code
		{
			printf("\t\"r3\" : 0x03 \"r6\" : 0x06   \"r1\" : 0x10\n\n");
			continue;
		}
		else if ( !strcmp( query, "r3") )
			RandomQuery( query, FUNC03 );       // make random code 0x03
		else if ( !strcmp( query, "r6") )
			RandomQuery( query, FUNC06 );       // make random code 0x06
		else if ( !strcmp( query, "r1") )
			RandomQuery( query, FUNC10 );       // make random code 0x10
		else if ( !isHexCode(query) || strlen(query)<12 )   // if incorrect query inputed
		{
			printf("\tplease input correct query\n\n");
			continue;
		}

		memcpy( sSlaveNum, (char *)&(query[0]), 2 );
		memcpy( sFuncCode, (char *)&(query[2]), 2 );
		memcpy( sRegiAdd, (char *)&(query[4]), 4 );
		// get Slave ID, Function code, Register start address from query

		nSlaveNum = strtol( sSlaveNum, NULL, 16 );
		nFuncCode = strtol( sFuncCode, NULL, 16 );
		nRegiAdd = strtol( sRegiAdd, NULL, 16);
		// translate string to uint variable

		switch ( nFuncCode )
		{
			/**/            case 0x03:      // 3    read multiple data in RW register
			/**/            case 0x04:      // 4    read multiple data in RO register
				{
					if ( strlen(query) != 12 )
						// func 0x03, 0x04 must have 16 byte len
						// last 4 byte is CRC
						// 16 - 4 = 12
					{
						printf("\tplease input correct query\n\n");
						break;          // switch break
					}

					memcpy( sRegiNum, (char *)&(query[8]), 4 );

					nRegiNum = strtol( sRegiNum, NULL, 16);

					rc = modbus_read_registers(ctx, nRegiAdd, nRegiNum, tab_rp_registers);
					// func 0x03 in modbus library

					if ( rc < 1 )
					{
						printf("read operation error\n");       // error
						break;                  // switch break
					}
					printf("\t----------------------------------------  Data  ----------------------------------------\n");
					printf("\t\t 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F\n");
					printf("\t----------------------------------------------------------------------------------------");
					for (i=0 , j=nRegiAdd%0x10; i<nRegiNum+j ; i++ )
					{
						if ( i%16 == 0 )
							printf("\n\t0x%02X\t", nRegiAdd-j+i);
						if ( i >= j && i < j+nRegiNum )
							printf(" %04X", *(tab_rp_registers+i-j));
						else
							printf("     ");
					}
					printf("\n\t----------------------------------------------------------------------------------------\n\n");
				}
				break;  // switch break
			/**/            case 0x06:      // 6    write one data in RW register
				{
					if ( strlen(query) != 12 )
						// func 0x06 must have 16 byte len
						// last 4 byte is CRC
						// 16 - 4 = 12
					{
						printf("\tplease input correct query\n\n");
						break;  // switch break
					}

					memcpy( sData, (char *)&(query[8]), 4 );

					nData = strtol( sData, NULL, 16);

					rc = modbus_write_register(ctx, nRegiAdd, nData);
					// func 0x06 in modbus library

					if ( rc != 1 )
					{
						printf("write operation error\n\n");
						break;          // switch break
					}

					printf("\n");
				}
				break;
			/**/            case 0x10:      // 16   write multiple data in RW register
				{
					memcpy( sRegiNum, (char *)&(query[8]), 4 );
					memcpy( sWriteNum, (char *)&(query[12]), 2 );

					nRegiNum = strtol( sRegiNum, NULL, 16);
					nWriteNum = strtol( sWriteNum, NULL, 16);

					if ( strlen(query) != 14+(nRegiNum*4)
							|| nWriteNum != nRegiNum*2 )
					{
						// func 0x06 must have 16 byte len
						// last 4 byte is CRC
						// 16 - 4 = 12
						printf("\tplease input correct query\n\n");
						break;          // switch break
					}

					for ( i=0 ; i< nRegiNum ; i++ )
					{
						memcpy( svData[i], (char *)&(query[14+(i*4)]), 4 );
						nvData[i] = strtol( svData[i], NULL, 16);
					}
					printf("\n");
					modbus_write_registers(ctx, nRegiAdd, nRegiNum, nvData);
					// func 0x10 in modbus library
				}
				break;  // switch break;
			default :
				printf("incorrect Function code.\n\n");        // function code is not 0x03, 0x06, 0x10
		}       // switch end
	}       // while end

	printf("interface end.\n");

	/* Free the memory */
	free(tab_rp_registers);
}
int main()
{
	//show_menu_main();
	BAN b[10];
	int iIndex =0;//No Data
	int choice;
label:	show_menu_main();
	printf("Input that you want choice : \n");
	scanf("%d",&choice);
	switch(choice){
	case 1:
		{
		Show_Create();
		InputMember(b,&iIndex,
			sizeof(b)/sizeof(b[0]));// Input run pointer point to iIndex address, get value iIndex ++
		goto label;
		break;
		}
	case 2:
		{
			Show_Output();
			PrintAll(b,iIndex);
			goto label;
			break;
		}
	case 3:
		Show_Searching();
		int chon;
		printf("Input choice that you searching!!!\n");
		scanf("%d",&chon);
		switch(chon){
		case 1:
			Searching_by_name(b,&iIndex);
			goto label;
			break;
		case 2:
			Searching_by_id(b,iIndex);
			goto label;
			break;
		}
	case 4:
		Show_Modify();
		Modify(b,iIndex);
		goto label;
		break;
	case 11:
		show_menu_EDIT();
		Edit(b,iIndex);
		goto label;
		break;
	case 5:
		show_list_delete();		
		//Delete(b,&iIndex);
		Delete_me(b,&iIndex);
		//PrintAll(b,iIndex);
		goto label;
		break;
	case 6:
		Show_delete_All();
		int de;
		printf("YOU WANT CHOICE ");
		scanf("%d",&de);
		switch(de){
		case 1:
			DeleteAll(b,&iIndex);
			goto label;
			break;
		case 2:
			goto label;
			break;
		}
	case 7:
		{
		show_menu_sort();
		int sort;
		printf("Please Input choice to sort data\n");
		scanf("%d",&sort);
		switch(sort){
		case 1:
			insertSort(b,iIndex);
			PrintAll(b,iIndex);
			goto label;
			break;
		case 2:
			sort_by_shell(b,iIndex);
			goto label;
			break;
		case 3:
			QuickSort(b,0,iIndex-1);
			PrintAll(b,iIndex);
			goto label;
			break;
		case 4:
			Merger_Sort_vision(b,0,iIndex-1);
			PrintAll(b,iIndex);
			goto label;
			break;
		}
		}
		break;
	case 8:
			save(b,iIndex);
			goto label;
		break;
	case 9:
		Show_data_read_file();
		ReadFile_1(b,iIndex,"ds.txt");
		goto label;
		break;
	case 10:
		exit(0);
		break;
	}
	return 0;
}
Beispiel #29
0
int main()
{
	HEAD* List = Create();

	SaveData data = { 0, 0, 0, 0 };
	
	EnQueue(List, data);

	char sel = 0;

	while (1)
	{
		printf("명령어 입력 : ");
		scanf("%s", &sel);

		switch (sel)
		{
		case '+':
			printf("Push 입력 : ");
			scanf("%d %d %d", &data.x, &data.y, &data.z);

			Push(List, data);
			PrintAll(List);
			break;
		case '-':
			Pop(List);
			PrintAll(List);
			break;
		case 'e':
			printf("EnQueue 입력 : ");
			scanf("%d %d %d", &data.x, &data.y, &data.z);

			EnQueue(List, data);
			PrintAll(List);
			break;
		case 'd':
			DeQueue(List);
			PrintAll(List);
			break;
		case 'l':
			printf("length of stack : %d \t length of queue : %d\n", stack_count, queue_count);
			break;
		case 'c':
			DeleteAll(List);
			break;
		case 'm':
			FindMaxNum(List);
			break;
		case 'n':
			FindMinNum(List);
			break;
		case 'q':
			break;
		default:
			break;
		}
	}
	

	return 0;
}