Пример #1
0
int main(int argc, char *argv[])
{
	example1();
	example2();

	return 0;
}
Пример #2
0
int main(int argc, char const *argv[])
{
	graph *g = example2();
	a_star_tree(g, 0, 4);
	cout << "\n\n";

	g = example2();
	a_star_graph(g, 0, 4);
	cout << "\n\n";

	g = example2();
	Disjkstra(g, 0, 4);
	cout << "\n\n";

	return 0;
}
Пример #3
0
int main(void)
{
   example1();
   example1b();
   example2();
   return 0;
}
Пример #4
0
int main()
{
    if (!ExampleFileUsage())
    {
        std::cerr << "ExampleFileUsage failed" << std::endl;
        return 1;
    }

    std::cerr << "ExampleFileUsage successful" << std::endl;


    if (!example2())
    {
        std::cerr << "example2 failed" << std::endl;
        return 1;
    }

    std::cerr << "example2 successful" << std::endl;

    if (!example3())
    {
        std::cerr << "example3 failed" << std::endl;
        return 1;
    }

    std::cerr << "example3 successful" << std::endl;

    return 0;
}
Пример #5
0
int main()
{
    example1();
    printf("-----------------------\n");
    example2();
    return 0;
}
Пример #6
0
void main()
{
	int *a1=example1(10);
	int *b1=example2(10);
	printf("%d\n",*a1);
	printf("%d\n",*b1);
}
Пример #7
0
int main()
{
    example1();
    example2();
    example3();
    example4();

    return 0;
}
Пример #8
0
    void nextArgument() const {
        givenACodeSampleToTokenize example1("foo(1, 2, 3, 4);");
        ASSERT_EQUALS(true, Token::simpleMatch(example1.tokens()->tokAt(2)->nextArgument(), "2 , 3"));
        ASSERT_EQUALS(true, Token::simpleMatch(example1.tokens()->tokAt(4)->nextArgument(), "3 , 4"));

        givenACodeSampleToTokenize example2("foo();");
        ASSERT_EQUALS(true, example2.tokens()->tokAt(2)->nextArgument() == 0);

        givenACodeSampleToTokenize example3("foo(bar(a, b), 2, 3);");
        ASSERT_EQUALS(true, Token::simpleMatch(example3.tokens()->tokAt(2)->nextArgument(), "2 , 3"));

        givenACodeSampleToTokenize example4("foo(x.i[1], \"\", 3);");
        ASSERT_EQUALS(true, Token::simpleMatch(example4.tokens()->tokAt(2)->nextArgument(), "\"\" , 3"));
    }
Пример #9
0
int main(int argc, char** argv)
{
    std::cout << "Hello, World!" << std::endl;

	ExampleOptional example1;
	example1.run();

	ExampleProgramOptions example2(argc, argv);
	example2.run();

	ExampleAny example3;
	example3.run();

    return 0;
}
Пример #10
0
int main () {
	int semid, shmid;
	unsigned short seminit[NUM_SEMS];
	struct common *shared;
	union semun semctlarg;
	struct customer *first_in_line;

	semid = semget(SEMKEY, NUM_SEMS, 0777 | IPC_CREAT);
	if (semid < 0) {
                perror("Could not get semaphores");
		exit(EXIT_FAILURE);
        }
	seminit[SEM_MUTEX]=1;
	seminit[SEM_WAITLIST]=0;
	semctlarg.array = seminit;
	semctl(semid, NUM_SEMS, SETALL, semctlarg);

	shmid = shmget(SHMKEY, sizeof(struct common), 0777 | IPC_CREAT);
	if (shmid < 0) {
                perror("Could not get shared memory");
       		exit(EXIT_FAILURE);
	 }
	shared=(struct common *)shmat(shmid, 0, 0);
	shared->wait_count = 0;
	shared->balance = 500;

	shmid = shmget(LINESTART, sizeof(struct customer), 0777 | IPC_CREAT);
	if (shmid < 0) {
                perror("Could not get shared memory");
		exit(EXIT_FAILURE);
        }
	first_in_line = (struct customer *)shmat(shmid, 0, 0);

	shared->customer_offset = LINESTART;
	shared->front_of_line = LINESTART;

	example1();
	example2();
	example3();

	semctl(semid, NUM_SEMS, IPC_RMID, 0);
	shmctl(shmid, IPC_RMID, 0);

	return EXIT_SUCCESS;
}
Пример #11
0
/*--------------------------------------------------------------------------*/
int main(void)
/* int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR szCmdLine, int iCmdShow) */
{
    if ( StartScilab(NULL, NULL, NULL) == FALSE ) printf("Error : StartScilab\n");
    printf("\nexample 1\n");
    example1();
    printf("\npress return\n");
    getchar();

    printf("\nexample 2\n");
    example2();
    printf("\npress return\n");
    getchar();

    printf("\nexample 3\n");
    example3();
    printf("\npress return\n");
    getchar();


    if ( TerminateScilab(NULL) == FALSE ) printf("Error : TerminateScilab\n");
    return 0;
}
Пример #12
0
int main(int argc, char **argv)
{
	int num;
	int i;
	char retval = 0;
	u_error_t *error = NULL;
	u_option_entry_t opt[] = {
		{"debug", 'd', U_OPTION_ARG_INT, &debug_level,
		 "Set the verbosity of debugging output.", "1-6"}
	};
	u_option_context_t *opt_ctx;
	opt_ctx = u_option_context_new("");
	u_option_context_set_ignore_unknown_options(opt_ctx, FALSE);
	u_option_context_add_main_entries(opt_ctx, opt, "wsmid_identify");
	retval = u_option_context_parse(opt_ctx, &argc, &argv, &error);

	u_option_context_free(opt_ctx);

	if (error) {
		if (error->message)
			printf("%s\n", error->message);
		u_error_free(error);
		return 1;
	}
	u_error_free(error);

	if (debug_level) {
		initialize_logging();
		wsman_debug_set_level(debug_level);
	}

	if (argc == 1) {
		// execute all
		example1();
		example2();
		example3();
		example4();
		example5();
		example6();
		example7();
		example8();
		example9();
		example10();
		example11();
		example12();
		example13();
		example14();
		return 0;
	}

	for (i = 1; i < argc; i++) {
		num = atoi(argv[i]);
		switch (num) {
		case 1:
			example1();
			break;
		case 2:
			example2();
			break;
		case 3:
			example3();
			break;
		case 4:
			example4();
			break;
	        case 5: 
			example5(); 
			break;
		case 6:
			example6();
			break;
		case 7:
			example7();
			break;
		case 8:
			example8();
			break;
		case 9:
			example9();
			break;
		case 10:
			example10();
			break;
		case 11:
			example11();
			break;
		case 12:
			example12();
			break;
		case 13:
			example13();
			break;
		case 14:
			example14();
			break;
		default:
			printf("\n    No example%d()\n", num);
			break;
		}
	}
	return 0;
}
Пример #13
0
// Dialog proc for the Windows window
int CALLBACK DialogProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case WM_INITDIALOG:
			hDlg = hWnd;
			break;

		case WM_CLOSE:
			EndDialog(hWnd, 0);
			break;

		case WM_DESTROY:
			PostQuitMessage(0);
			break;

		case WM_COMMAND:
		{
			if (HIWORD(wParam) != BN_CLICKED)
				break;

			SetWindowText(GetDlgItem(hWnd, IDC_OUTPUT), L"");

			switch (LOWORD(wParam))
			{
				case IDC_VERIFY:
				case IDC_ECHO:
				{
					int size = GetWindowTextLength(GetDlgItem(hWnd, IDC_INPUT));
					wchar_t* text = new wchar_t[size + 1];
					GetWindowText(GetDlgItem(hWnd, IDC_INPUT), text, size + 1);

					JSONValue *value = JSON::Parse(text);

					if (value == NULL)
					{
						SetWindowText(GetDlgItem(hWnd, IDC_OUTPUT), L"The JSON text *is not* valid");
					}
					else
					{
						if (LOWORD(wParam) == IDC_ECHO)
							SetWindowText(GetDlgItem(hWnd, IDC_OUTPUT), value->Stringify().c_str());
						else
							SetWindowText(GetDlgItem(hWnd, IDC_OUTPUT), L"The JSON text *is* valid");
						delete value;
					}

					delete text;
					break;
				}

				case IDC_EX1:
					extern const wchar_t *EXAMPLE;
					SetWindowText(GetDlgItem(hDlg, IDC_INPUT), EXAMPLE);
					example1();
					break;

				case IDC_EX2:
					SetWindowText(GetDlgItem(hDlg, IDC_INPUT), L"Example 2:\r\n\r\nKey 'test_string' has a value 'hello world'\r\nKey 'sample_array' is an array of 10 random numbers");
					example2();
					break;

				case IDC_TESTCASES:
					SetWindowText(GetDlgItem(hWnd, IDC_INPUT), L"");
					run_tests();
					break;
			}

			break;
		}
	}

	return 0;
}
Пример #14
0
int main() {
	std::cout << "*** Running example1 ***" << std::endl;
	example1();
	std::cout << "*** Running example2 ***" << std::endl;
	example2();
}