├── .gitignore ├── .gitmodules ├── C++_AIS ├── prac2 │ ├── de-MyPinTool.cpp │ └── en-MyPinTool.cpp ├── prac3.1 │ ├── README.md │ ├── main.py │ ├── requirements.txt │ └── test.sh └── prac3.2 │ ├── README.md │ ├── main.py │ └── test.sh ├── C++_ALGEBRA ├── TEST1 │ ├── 1.zip │ └── matrix.cpp ├── TEST2 │ ├── 2.zip │ ├── QRmatrix.cpp │ ├── make_qr.cpp │ └── task_2c.txt └── TEST3 │ └── 3.zip ├── C++_ANALYSIS ├── 9_3.py ├── Cauchy_problem.cpp ├── Differential.equation.cpp ├── Integral_equation_kind_1.cpp ├── Integral_equation_kind_2.cpp ├── integral.cpp ├── matrix.cpp ├── matrix_Householder.cpp ├── matrix_iteration.cpp ├── matrix_iteration_tr.cpp ├── min_Grad.cpp ├── min_Newton.cpp └── temp.py ├── C++_CLASS_TEST ├── Client_Database.cpp ├── Dec_1 │ ├── box.cpp │ ├── complex.cpp │ ├── elec_counter.cpp │ ├── fraction.cpp │ ├── mystack.cpp │ ├── mystring.cpp │ ├── myvector.cpp │ ├── test1.cpp │ ├── test2.cpp │ ├── test3.cpp │ └── test4.cpp ├── Dec_15 │ ├── VVK.4.14.cpp │ ├── VVK.4.15.cpp │ ├── VVK.4.3.cpp │ ├── VVK.4.7.cpp │ ├── VVK.4.9.cpp │ ├── list.cpp │ ├── list.h │ └── main.cpp ├── Dec_22 │ ├── VVK.5.1.cpp │ ├── VVK.5.10.cpp │ ├── VVK.5.2.cpp │ ├── VVK.5.3.cpp │ ├── VVK.5.4.cpp │ ├── VVK.5.5.cpp │ ├── VVK.5.6.cpp │ ├── VVK.5.7.cpp │ ├── VVK.6.3.a.cpp │ ├── VVK.6.3.b.cpp │ ├── VVK.6.3.c.cpp │ ├── VVK.6.4.a.cpp │ ├── VVK.6.4.b.cpp │ ├── VVK.6.4.c.cpp │ ├── VVK.6.5.cpp │ ├── VVK.6.6.cpp │ ├── VVK.7.1.cpp │ ├── temp.cpp │ ├── test10.cpp │ └── test9.cpp ├── Dec_29 │ ├── VVK.8.4.cpp │ ├── VVK.8.6.cpp │ ├── VVK.8.6_friend.cpp │ └── test1.cpp ├── Dec_8 │ ├── K.1.14.a.cpp │ ├── K.1.14.b.cpp │ ├── K.2.1.cpp │ ├── K.2.3.cpp │ ├── K.2.4.cpp │ ├── VVK.1.11.cpp │ ├── VVK.1.12.cpp │ ├── VVK.1.13.cpp │ ├── VVK.1.14.cpp │ ├── VVK.1.16.cpp │ ├── VVK.1.17.cpp │ ├── VVK.1.18.cpp │ ├── VVK.1.21.cpp │ ├── VVK.1.3.b.cpp │ ├── VVK.1.4.cpp │ ├── VVK.1.7.cpp │ ├── VVK.1.8.cpp │ ├── t.cpp │ └── temp.cpp ├── Jan_12 │ ├── 1.txt │ ├── 2.a_b_c_d.txt │ ├── abcd.txt │ ├── fibo.txt │ ├── interpreter.cpp │ ├── interpreter_char.cpp │ ├── interpreter_old.cpp │ ├── t.txt │ └── temp.cpp ├── Jan_7 │ ├── VVK.9.13.cpp │ ├── VVK.9.14.cpp │ ├── VVK.9.16.cpp │ ├── VVK.9.31.cpp │ ├── temp │ ├── test2.cpp │ └── test3.cpp ├── Koloc │ ├── fread.c │ ├── res.txt │ ├── temp.c │ ├── test1.cpp │ ├── test2.cpp │ ├── test3.cpp │ ├── test4.cpp │ ├── test5.cpp │ ├── test6.cpp │ ├── test7.cpp │ └── test8.cpp ├── Server_Database.cpp ├── Shape │ ├── Shape.cpp │ ├── Shape.h │ ├── main.cpp │ ├── makefile │ └── people.cpp ├── Table.c ├── Table.h ├── exam │ ├── test1.cpp │ ├── test2.cpp │ ├── test3.cpp │ ├── test6.cpp │ ├── test7.cpp │ └── test8.cpp ├── ourtest.txt ├── s.cpp ├── shape.cpp ├── shape.h ├── smartPoint.cpp ├── t.cpp ├── test1.cpp ├── test10.cpp ├── test11.cpp ├── test12.cpp ├── test13.cpp ├── test14.cpp ├── test15.cpp ├── test16.cpp ├── test2.cpp ├── test3.cpp ├── test4.cpp ├── test5.cpp ├── test6.cpp ├── test7.cpp ├── test8.cpp └── test9.cpp ├── C++_HPC ├── bsort.cpp └── parallel_sort_new.cpp ├── C++_LECTURE ├── .vscode │ └── settings.json ├── Algorithms │ ├── .vscode │ │ └── settings.json │ ├── BasicData.cpp │ ├── BooleanFunction.cpp │ ├── DataAVL.cpp │ ├── IntPartition.cpp │ ├── IntegerPatition.cpp │ ├── Vision.cpp │ ├── complex.cpp │ ├── quicksort.cpp │ └── temp.cpp ├── Combinaaatorics │ ├── Combination1.cpp │ ├── Combination2.cpp │ ├── Gray_code.cpp │ ├── Permutation1.cpp │ ├── Permutation2.cpp │ └── temp.cpp ├── Function │ ├── 5.cpp │ ├── Complex.cpp │ ├── ExponentComplex.cpp │ ├── Exponent_Complex.cpp │ ├── Input_Grammar.cpp │ ├── Integral.cpp │ ├── Math.cpp │ ├── Matrix.cpp │ ├── bilety.cpp │ └── marloren.cpp ├── Linked_list │ ├── AVLTree.cpp │ ├── Abstract.cpp │ ├── Array.cpp │ ├── BTree.cpp │ ├── Bool.cpp │ ├── Singly_linked_list.cpp │ ├── Tree.cpp │ └── main.cpp ├── Matrix │ ├── Matrix.cpp │ └── Matrix_temp.cpp ├── Sort │ └── Basic_sort.cpp ├── Student_scores │ ├── main │ ├── main.cpp │ ├── main.o │ ├── students.cpp │ ├── students.h │ ├── students.o │ ├── test1.cpp │ └── test2.cpp ├── Super_Calculation │ ├── Formula.cpp │ ├── SuperNumber_Exponent.cpp │ ├── SuperNumber_Factorial.cpp │ ├── Super_Calculation.c │ ├── digits.cpp │ ├── digits │ │ ├── PowerSimple.cpp │ │ ├── sum_digits3.cpp │ │ ├── test_digits2.cpp │ │ ├── test_digits2_temp.cpp │ │ ├── test_digits3.cpp │ │ ├── test_digits3_temp.cpp │ │ └── test_digits4.cpp │ ├── digits1.cpp │ ├── digits1_temp.cpp │ ├── digits3.cpp │ ├── digits4.cpp │ ├── digits4_temp.cpp │ ├── digits_temp.cpp │ └── test.cpp └── TSP │ ├── README.md │ ├── TSP.cpp │ ├── input.txt │ ├── input1.txt │ └── miniDNF.cpp ├── C++_LIBRARY ├── LogUtils.cc └── LogUtils.h ├── C++_PARALLEL ├── Chapter_BigInteger │ ├── BigInteger.h │ ├── BrocardProblem.cpp │ ├── README.md │ ├── test1.cpp │ ├── test2.cpp │ └── test3.cpp ├── Chapter_Class │ ├── MPI1Proc1.cpp │ ├── MPI1Proc9.cpp │ ├── MPI2Send14.cpp │ ├── MPI2Send15.cpp │ ├── MPI2Send19.cpp │ ├── MPI2Send21.cpp │ ├── MPI2Send24.cpp │ ├── MPI2Send4.cpp │ ├── MPI2Send7.cpp │ ├── MPI2Send9.cpp │ ├── MPI3Coll18.cpp │ ├── MPI3Coll25.cpp │ ├── MPI3Coll5.cpp │ ├── MPI3Coll8.cpp │ ├── MPI4Type16.cpp │ ├── MPI4Type17.cpp │ ├── MPI4Type19.cpp │ ├── MPI4Type22.cpp │ ├── MPI4Type9.cpp │ ├── MPI5Comm10.cpp │ ├── MPI5Comm13.cpp │ ├── MPI5Comm18.cpp │ ├── MPI5Comm2.cpp │ ├── MPI5Comm22.cpp │ ├── MPI5Comm24.cpp │ ├── MPI5Comm26.cpp │ ├── MPI5Comm28.cpp │ ├── MPI5Comm31.cpp │ ├── MPI5Comm6.cpp │ ├── MPI6File12.cpp │ ├── MPI6File15.cpp │ ├── MPI6File18.cpp │ ├── MPI6File2.cpp │ ├── MPI6File22.cpp │ ├── MPI6File23.cpp │ ├── MPI6File26.cpp │ ├── MPI6File27.cpp │ ├── MPI6File30.cpp │ ├── MPI6File5.cpp │ ├── MPI6File9.cpp │ ├── MPI7Win1.cpp │ ├── MPI7Win14.cpp │ ├── MPI7Win17.cpp │ ├── MPI7Win18.cpp │ ├── MPI7Win21.cpp │ ├── MPI7Win26.cpp │ ├── MPI7Win27.cpp │ ├── MPI7Win29.cpp │ ├── MPI7Win30.cpp │ ├── MPI7Win6.cpp │ ├── MPI7Win7.cpp │ ├── MPI8Inter10.cpp │ ├── MPI8Inter13.cpp │ ├── MPI8Inter15.cpp │ ├── MPI8Inter16.cpp │ ├── MPI8Inter17.cpp │ ├── MPI8Inter2.cpp │ ├── MPI8Inter20.cpp │ ├── MPI8Inter21.cpp │ ├── MPI8Inter4.cpp │ ├── MPI8Inter5.cpp │ ├── MPI8Inter8.cpp │ ├── MPI8Inter9.cpp │ ├── MPI9Matr14.cpp │ ├── MPI9Matr15.cpp │ ├── MPI9Matr17.cpp │ ├── MPI9Matr18.cpp │ ├── MPI9Matr19.cpp │ ├── MPI9Matr20.cpp │ ├── MPI9Matr26.cpp │ ├── MPI9Matr27.cpp │ ├── MPI9Matr32.cpp │ ├── MPI9Matr33.cpp │ ├── MPI9Matr35.cpp │ ├── MPI9Matr36.cpp │ ├── MPI9Matr42.cpp │ ├── MPI9Matr43.cpp │ ├── MPIGravit4.cpp │ ├── OMPBegin1.cpp │ ├── OMPBegin11.cpp │ ├── OMPBegin16.cpp │ └── OMPBegin7.cpp ├── Chapter_Factorial │ ├── BigInteger.h │ ├── test1.cpp │ ├── test2.cpp │ └── test3.cpp ├── Chapter_Sort │ ├── ParallelProgram1.cpp │ ├── ParallelProgram2.cpp │ └── ParallelProgram3.cpp └── Chapter_Tutorial │ ├── Gravity.cpp │ ├── test1.cpp │ ├── test10.cpp │ ├── test2.cpp │ ├── test3.cpp │ ├── test4.cpp │ ├── test5.cpp │ ├── test6.cpp │ ├── test7.cpp │ ├── test8.cpp │ └── test9.cpp ├── C++_SC ├── task1 │ ├── program_213.c │ └── program_213.xml └── task2 │ ├── Makefile │ ├── include │ ├── cube.hpp │ ├── parallel_solver.hpp │ ├── parser.hpp │ ├── printer.hpp │ ├── serial_solver.hpp │ ├── solver.hpp │ ├── task.hpp │ └── timer.hpp │ ├── main.cpp │ └── scripts │ ├── download.sh │ ├── graph.py │ ├── graph.sh │ ├── graph_3d.py │ ├── show.sh │ ├── submit.sh │ ├── submit_mpi.sh │ ├── table.py │ ├── table_mpi.py │ └── upload.sh ├── CA_PP └── sort_three.c ├── C_BASIC ├── Chapter1 │ ├── test1.c │ ├── test10.c │ ├── test11.c │ ├── test12.c │ ├── test13.c │ ├── test14.c │ ├── test2.c │ ├── test3.c │ ├── test4.c │ ├── test5.c │ ├── test6.c │ ├── test7.c │ ├── test8.c │ └── test9.c ├── Chapter2 │ ├── test1.c │ ├── test10.c │ ├── test11.c │ ├── test12.c │ ├── test13.c │ ├── test14.c │ ├── test15.c │ ├── test16.c │ ├── test17.c │ ├── test18.c │ ├── test19.c │ ├── test2.c │ ├── test20.c │ ├── test21.c │ ├── test22.c │ ├── test23.c │ ├── test24.c │ ├── test25.c │ ├── test26.c │ ├── test27.c │ ├── test28.c │ ├── test29.c │ ├── test3.c │ ├── test30.c │ ├── test31.c │ ├── test32.c │ ├── test4.c │ ├── test5.c │ ├── test6.c │ ├── test7.c │ ├── test8.c │ └── test9.c ├── Chapter3 │ ├── test1.c │ ├── test2.c │ ├── test3.c │ ├── test4.c │ ├── test5.c │ ├── test6.c │ ├── test7.c │ └── test8.c └── Chapter4 │ ├── test1.c │ ├── test10.c │ ├── test11.c │ ├── test15.c │ ├── test16.c │ ├── test17.c │ ├── test19.c │ ├── test2.c │ ├── test3.c │ ├── test4.c │ ├── test5.c │ ├── test6.c │ ├── test7.c │ ├── test8.c │ └── test9.c ├── C_CLASS_NEWTEST ├── Array │ ├── Eratosthenes.c │ ├── test1-7.c │ ├── test10.c │ ├── test11.c │ ├── test12.c │ ├── test15.c │ ├── test16.c │ ├── test2.c │ ├── test8.c │ └── test8_b.c ├── Chapter1 │ ├── test1.c │ ├── test10.c │ ├── test11.c │ ├── test12.c │ ├── test13.c │ ├── test14.c │ ├── test15.c │ ├── test16.c │ ├── test17.c │ ├── test2.c │ ├── test3.c │ ├── test4.c │ ├── test5.c │ ├── test6.c │ ├── test7.c │ ├── test8.c │ └── test9.c ├── Class │ └── test.c ├── Function │ ├── test1.c │ ├── test2.c │ ├── test3.c │ └── test4_9.c ├── Function_arg │ ├── test1.c │ ├── test2.c │ ├── test3.c │ ├── test4.c │ ├── test5.c │ ├── test6.c │ ├── test6_temp.cpp │ └── test7.c ├── Lecture │ ├── Heapsort │ ├── Heapsort.c │ ├── Heapsort_test.c │ ├── Quicksort │ ├── Quicksort.c │ ├── Quicksort_temp.c │ ├── Recursive.c │ ├── Super_Calculation.c │ ├── Time │ ├── Time.c │ ├── division.c │ └── hello.c ├── Linked_list │ ├── AVLtree.c │ ├── Count.c │ ├── Mydeque.c │ ├── Myqueue.c │ ├── Mytree.c │ ├── Search_tree.c │ ├── Singly_linked_list.c │ ├── deque.c │ ├── list.c │ ├── list_calculator.c │ ├── list_calculator1.c │ ├── list_char1.c │ ├── list_char2.c │ ├── list_dim.c │ ├── list_period.c │ ├── myfile │ ├── queue.c │ ├── temp.c │ ├── tree.c │ ├── tree_print.c │ ├── tree_reverse.c │ └── wc.c ├── Pointer │ ├── test1.c │ ├── test2.c │ ├── test3.c │ ├── test4.c │ ├── test5.c │ └── test6.c ├── Sort │ ├── Basic_sort.c │ └── Sort_2.c ├── Sort_raw_file │ ├── Bubblesort_raw_file.c │ ├── Mergesort_raw_file.c │ ├── Quicksort_raw_file.c │ ├── fread.c │ ├── fwrite.c │ ├── newSort_temp.c │ └── sort_raw_file.c ├── String │ ├── KMP.c │ ├── KMP.cpp │ ├── test1.c │ ├── test2.c │ ├── test3.c │ ├── test4.c │ ├── test6.c │ └── test7.c ├── Structure │ ├── temp.c │ └── test1.c ├── Task │ ├── copy │ ├── myfile │ ├── myfile1 │ ├── myfile2 │ ├── temp │ ├── temp.c │ ├── temp1.c │ ├── test1.c │ ├── test10.c │ ├── test11.c │ ├── test12.c │ ├── test13.c │ ├── test14.c │ ├── test15.c │ ├── test16.c │ ├── test17.c │ ├── test18.c │ ├── test19.c │ ├── test2.c │ ├── test20.c │ ├── test21.c │ ├── test22.c │ ├── test23.c │ ├── test24.c │ ├── test25.c │ ├── test26.c │ ├── test27.c │ ├── test28.c │ ├── test29.cpp │ ├── test3.c │ ├── test30.cpp │ ├── test31.c │ ├── test32.c │ ├── test33.c │ ├── test34.c │ ├── test35.c │ ├── test36.c │ ├── test37.c │ ├── test38.c │ ├── test38_temp.c │ ├── test38_temp1.c │ ├── test38_temp2.c │ ├── test38_temp3.c │ ├── test39.c │ ├── test4.c │ ├── test40.c │ ├── test41.c │ ├── test41_temp.c │ ├── test42.c │ ├── test43.c │ ├── test44.c │ ├── test45.c │ ├── test5.c │ ├── test6.c │ ├── test7.c │ ├── test8.c │ └── test9.c └── test │ ├── test1.c │ ├── test2.c │ ├── test3.c │ ├── test4.c │ ├── test5.c │ ├── test6.c │ └── test7.c ├── C_CLASS_TEST ├── input │ ├── input_test128.txt │ └── input_test129.txt ├── output │ ├── output_test128.txt │ └── output_test129.txt ├── test1.c ├── test10.c ├── test100.c ├── test101.c ├── test102.c ├── test103.c ├── test104.c ├── test105.c ├── test106.c ├── test107.c ├── test108.c ├── test109.c ├── test11.c ├── test110.c ├── test111.c ├── test112.c ├── test113.c ├── test114.c ├── test115.c ├── test116.c ├── test117.c ├── test118.c ├── test119.c ├── test12.c ├── test120.c ├── test121.c ├── test122.c ├── test123.c ├── test124.c ├── test125.c ├── test126.c ├── test127.c ├── test128.c ├── test129.c ├── test13.c ├── test130.c ├── test131.c ├── test132.c ├── test133.c ├── test14.c ├── test15.c ├── test16.c ├── test17.c ├── test18.c ├── test19.c ├── test2.c ├── test20.c ├── test21.c ├── test22.c ├── test23.c ├── test24.c ├── test25.c ├── test26.c ├── test27.c ├── test28.c ├── test29.c ├── test3.c ├── test30.c ├── test31.c ├── test32.c ├── test33.c ├── test34.c ├── test35.c ├── test36.c ├── test37.c ├── test38.c ├── test39.c ├── test4.c ├── test40.c ├── test41.c ├── test42.c ├── test43.c ├── test44.c ├── test45.c ├── test46.c ├── test47.c ├── test48.c ├── test49.c ├── test5.c ├── test50.c ├── test51.c ├── test52.c ├── test53.c ├── test54.c ├── test55.c ├── test56.c ├── test57.c ├── test58.c ├── test59.c ├── test6.c ├── test60.c ├── test61.c ├── test62.c ├── test63.c ├── test64.c ├── test65.c ├── test66.c ├── test67.c ├── test68.c ├── test69.c ├── test7.c ├── test70.c ├── test71.c ├── test72.c ├── test73.c ├── test74.c ├── test75.c ├── test76.c ├── test77.c ├── test78.c ├── test79.c ├── test8.c ├── test80.c ├── test81.c ├── test82.c ├── test83.c ├── test84.c ├── test85.c ├── test86.c ├── test87.c ├── test88.c ├── test89.c ├── test9.c ├── test90.c ├── test91.c ├── test92.c ├── test93.c ├── test94.c ├── test95.c ├── test96.c ├── test97.c ├── test98.c ├── test99.c └── test_a.c ├── C_UNIX ├── Chapter_CHOWN │ ├── Chown_group.c │ ├── Chown_matrix.c │ ├── Chown_usr.c │ ├── Hello.c │ ├── Mylink.c │ └── Stat_modify.c ├── Chapter_COMMAND │ └── Myls.cpp ├── Chapter_DUP │ ├── temp.c │ ├── test1.c │ ├── test10.c │ ├── test10_temp.c │ ├── test11.c │ ├── test12.c │ ├── test13.c │ ├── test14.c │ ├── test15.c │ ├── test16.c │ ├── test17.c │ ├── test18.c │ ├── test18_temp.c │ ├── test19.c │ ├── test2.c │ ├── test3.c │ ├── test4.c │ ├── test5.c │ ├── test6.c │ ├── test7.c │ ├── test8.c │ └── test9.c ├── Chapter_EXAM │ ├── newtest2.c │ ├── newtest2_mmap.c │ ├── newtest2_pipe.c │ ├── newtest2_sigaction.c │ ├── newtest2_signal.c │ ├── newtest5.c │ ├── t.c │ ├── t1.c │ ├── t2.c │ ├── t3.c │ ├── t4_client.c │ ├── t4_server.c │ ├── temp.c │ ├── temp2.c │ ├── test1.c │ ├── test2.c │ ├── test3.c │ ├── test3_temp.c │ ├── test4.c │ ├── test4_temp.c │ └── test5.c ├── Chapter_EXECL │ ├── 1.c │ ├── 2.c │ ├── Execl.c │ ├── Execl_lm_execl_1.c │ ├── Execl_lm_execv_1.c │ ├── Execl_ls.c │ ├── Execl_ls_pwd_ps.c │ ├── Execl_mmap_3.c │ ├── Execl_run_2.c │ ├── Execl_test.c │ └── test.c ├── Chapter_FILE │ ├── 10.txt │ ├── 13.txt │ ├── 13_f1.txt │ ├── 13_f2.txt │ ├── 14.txt │ ├── 15_input.txt │ ├── 15_output.c │ ├── 16_input.txt │ ├── 16_output.txt │ ├── 17_input1.txt │ ├── 17_input2.txt │ ├── 17_output.txt │ ├── 6.txt │ ├── 7.txt │ ├── 8.txt │ ├── 9.txt │ ├── 9f.txt │ ├── 9g.txt │ ├── Append_10.c │ ├── Append_9.c │ ├── Append_f_g.c │ ├── Array_15.c │ ├── Array_16.c │ ├── Array_17.c │ ├── Copy_4.c │ ├── Copy_5.c │ ├── Copy_6.c │ ├── Copy_7.c │ ├── Delete_8.c │ ├── Function_14.c │ ├── Get_11.c │ ├── Merge_12.c │ ├── Merge_13.c │ ├── fread.c │ ├── fwrite.c │ └── temp.txt ├── Chapter_KONC │ ├── test1.c │ ├── test2.c │ └── test3.c ├── Chapter_MSG │ ├── client.c │ ├── client_wyr.c │ ├── client_wzq.c │ ├── memory.h │ ├── messages.h │ ├── messages_one.c │ ├── messages_two.c │ ├── ncat.c │ ├── philosopher.c │ ├── read_from_shmem.c │ ├── read_from_shmem_sem.c │ ├── reader.c │ ├── server.c │ ├── server1.c │ ├── server_wyr.c │ ├── server_wzq.c │ ├── test1.c │ ├── test2.c │ ├── test3.c │ ├── test4.c │ ├── write_to_shmem.c │ ├── write_to_shmem_sem.c │ └── writer.c ├── Chapter_PIPE │ ├── 1.txt │ ├── 2.txt │ ├── 3.txt │ ├── 5.txt │ ├── res.txt │ ├── test1.c │ ├── test2.c │ ├── test3.c │ ├── test4.c │ ├── test5.c │ └── test5_temp.c ├── Chapter_PROCESS │ ├── 1.txt │ ├── GetPid.c │ ├── divid.c │ └── mydivid.c ├── Chapter_STAT │ ├── CaculateMatrix_mmap_5.c │ ├── CaculateMatrix_read_5.c │ ├── Delete_mmap_1.c │ ├── Delete_write_1.c │ ├── InputComplexMatrix_mmap_3.c │ ├── InputComplexMatrix_write_3.c │ ├── InputMatrix_mmap_2.c │ ├── InputMatrix_write_2.c │ ├── OutputMatrix_mmap_4.c │ ├── OutputMatrix_read_4.c │ ├── Stat_size.c │ ├── fread_complex.c │ └── fread_matrix.c ├── Chapter_TEST │ ├── test1.c │ ├── test2.c │ ├── test2_2.c │ ├── test3.c │ ├── test4.c │ ├── test4_2.c │ └── test5.c └── Temp │ ├── 1.txt │ ├── MyShell.c │ ├── create n process.c │ ├── dup.c │ ├── process_n.c │ └── shell_tmp.c ├── GRAPHIC_BASIC ├── Задание1-RayTracing │ └── raytracer.cpp └── Задание2-OpenGL │ ├── Wall.bmp │ └── moving_texture.py ├── HASKELL_BASIC ├── LU_expansion.hs ├── LinearSystem.hs ├── exam.hs ├── exam │ ├── exam.hs │ ├── exam16.hs │ ├── exam18.hs │ ├── exam20.hs │ ├── exam21.hs │ ├── swapMatrix.hs │ ├── t.hs │ └── temp.hs ├── inverse_matrix1.hs ├── square_eq.hs ├── temp.hs ├── test1.hs ├── test10.hs ├── test11.hs ├── test12.hs ├── test13.hs ├── test14.hs ├── test15.hs ├── test16.hs ├── test17.hs ├── test18.hs ├── test19.hs ├── test2.hs ├── test20.hs ├── test21.hs ├── test22.hs ├── test23.hs ├── test24.hs ├── test3.hs ├── test4.hs ├── test5.hs ├── test6.hs ├── test7.hs ├── test8.hs ├── test9.hs └── tmp.hs ├── INSECON ├── task1 │ ├── docker-compose.yml │ ├── task1.1.sh │ ├── task1.2.sh │ ├── task1.3_docker.sh │ ├── task1.3_ocsp.sh │ └── task1.3_verify.sh ├── task2 │ ├── ci.sh │ ├── sqli.sh │ └── zip.sh └── task3 │ ├── task3.1 │ ├── acl.sh │ ├── capture_acl.sh │ ├── capture_ua.sh │ ├── squid.conf.default │ ├── ua.sh │ └── zip.sh │ └── task3.2 │ ├── acl.sh │ ├── bump.sh │ ├── capture_acl.sh │ ├── capture_bump.sh │ ├── squid.conf.default │ ├── task3.2.sh │ └── zip.sh ├── JAVA_BASIC ├── Practice1_socket │ └── CarClient.java ├── Practice2_rmi │ ├── RMICarServer.java │ └── RemoteCarClient.java ├── Practice3_webservice │ └── client.java ├── Practice4_grpc │ └── CarClient.java ├── Practice5_jms │ └── Client.java └── Practice6_kafaka │ └── KafkaSimpleClient.java ├── LICENSE ├── MODEL_CHECKING ├── CLASS │ ├── NUSMV │ │ ├── counter_cell.smv │ │ ├── hanoi.smv │ │ ├── main.smv │ │ ├── peterson.smv │ │ └── wolf_goat_cabbage.smv │ └── PROMELA │ │ ├── abp.pml │ │ ├── euclid.pml │ │ ├── hanoi_tower.pml │ │ ├── main.pml │ │ ├── mutual_exclusion.pml │ │ ├── peterson.pml │ │ ├── ping_pong.pml │ │ ├── wolf_goat_cabbage.pml │ │ └── wolf_goat_cabbage_2.pml ├── PRAC │ ├── TASK1 │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── inc │ │ │ ├── fsm.hpp │ │ │ ├── ltl.hpp │ │ │ └── translator.hpp │ │ ├── run.sh │ │ ├── src │ │ │ ├── fsm.cpp │ │ │ ├── ltl.cpp │ │ │ └── translator.cpp │ │ └── test │ │ │ └── test.cpp │ ├── TASK2 │ │ ├── Makefile │ │ ├── bdd.cpp │ │ ├── bdd.h │ │ ├── formula.cpp │ │ ├── formula.h │ │ └── test.cpp │ └── TASK3 │ │ ├── Makefile │ │ ├── README.md │ │ ├── dpll.cpp │ │ ├── dpll.hpp │ │ └── test.cpp └── TEST │ ├── Variant4 │ ├── prepare-2.pml │ └── prepare.pml │ ├── Variant5 │ └── boys_and_soldiers.pml │ └── Variant6 │ ├── 6_1.pml │ └── 6_2.pml ├── README.md ├── R_BASIC ├── .Rhistory ├── 5.R ├── 9.1.R ├── 9.2.R ├── 9.3.R ├── Bernulli.R ├── DJIA.R ├── Zan11 │ ├── genBinom.R │ ├── grBin.R │ ├── grBinN.R │ ├── grNor.R │ └── returnApple.R ├── Zan12 │ ├── .Rhistory │ ├── Gspc500.R │ ├── Nasdaq100.R │ ├── Nyse100.R │ ├── SSEC.R │ ├── hist_binomial.R │ ├── quan_norm.R │ ├── quantmod.pdf │ ├── returnApple.R │ ├── returnApple_daily_yadDen.R │ ├── returnApple_monthly_yadDen.R │ └── returnApple_weekly_yadDen.R ├── Zan14 │ ├── .RData │ ├── .Rhistory │ ├── 14.1.R │ ├── 14.2.R │ ├── 14.3.R │ ├── AAPL_DJI_CLOSE.pdf │ ├── AAPL_DJI_CLOSE.txt │ ├── Index3Get.R │ ├── gr3Dim.R │ ├── grNorm.R │ ├── iAP.csv │ └── iDJ.csv ├── Zan15 │ ├── .Rhistory │ ├── AR1.inp │ ├── ARMA.m │ ├── Graph_y1.png │ ├── Graph_y2.png │ ├── Graph_y3.png │ ├── Homework15_2.R │ ├── Homework15_2.gdt │ ├── Homework15_2.m │ ├── gr_1.m │ └── mat1.m ├── Zan16 │ ├── .Rhistory │ └── Homework16.R ├── Zan8 │ ├── Homework │ │ ├── Answer1 │ │ │ ├── Matrix_bonds_1.txt │ │ │ ├── Matrix_bonds_2.txt │ │ │ ├── Matrix_plot_1.png │ │ │ ├── Matrix_plot_2.png │ │ │ ├── Matrix_price_1.txt │ │ │ ├── Matrix_price_2.txt │ │ │ ├── OLSdannyeBonds_1.R │ │ │ └── OLSdannyeBonds_2.R │ │ ├── Answer2 │ │ │ ├── .Rhistory │ │ │ ├── LeastSquares_bonds.txt │ │ │ ├── LeastSquares_price.txt │ │ │ ├── OLSdannyeBondsReg.R │ │ │ └── Reg.txt │ │ ├── NS.R │ │ ├── NelsonSig.R │ │ ├── xtsCr.R │ │ └── Занятие 8.xlsx │ ├── NS.R │ ├── NelsonSig.R │ ├── OLSdannyeBonds.R │ ├── OLSdannyeBondsReg.R │ └── xtsCr.R ├── app_durattion1.R ├── approx_conv.R ├── approx_duration.R ├── bondDuration.R ├── bondPrice_r.R ├── bondPrice_r_convex.R ├── bondconv_i.R ├── bondconv_r.R ├── datFR.R ├── duration2years.R ├── exampleDF.R ├── fromWB.R ├── ger_UniF.R ├── grNor.R ├── grSinDuration.R ├── importAAPL_XPT.R ├── nerChebysh.R ├── priceYield.R ├── probUnit.R ├── pv12.R ├── returnApple │ ├── result.txt │ ├── returnAppleDaily.R │ ├── returnAppleMonthly.R │ ├── returnAppleQuarterly.R │ ├── returnAppleWeekly.R │ └── returnAppleYearly.R ├── testFunc.R ├── typeMatrx.R ├── typeVec.R ├── typeVector.R ├── wbSearch.R ├── yieldBond.R └── yieldBonds.R ├── UNIX_NETWORK ├── Chapter_MULTIPLE │ ├── server_epoll.cpp │ ├── server_epoll_reactor.cpp │ ├── server_poll.cpp │ ├── server_process.cpp │ ├── server_pthread.cpp │ └── server_select.cpp ├── Chapter_PTHREAD │ ├── makefile │ ├── threadpool.c │ └── threadpool.h ├── Chapter_SINGLE │ ├── 1.2.cpp │ ├── 1.5.cpp │ ├── client.cpp │ ├── server.cpp │ ├── wrap.cpp │ └── wrap.h ├── Chapter_UDP │ ├── client.c │ ├── makefile │ └── server.c └── Chapter_WEB │ ├── README.md │ ├── inc │ └── web_server.h │ ├── makefile │ └── src │ ├── main.cpp │ └── web_server.cpp ├── UNIX_SYSTEM ├── Chapter_COMMAND │ └── myls_R.cpp ├── Chapter_DYNAMIC │ ├── inc │ │ └── mymath.h │ ├── lib │ │ └── libmymath.so │ ├── note.txt │ ├── src │ │ ├── add.cpp │ │ ├── add.o │ │ ├── sub.cpp │ │ └── sub.o │ └── test.cpp ├── Chapter_FILE │ ├── test1.cpp │ └── test2.cpp ├── Chapter_FORK │ ├── dup.cpp │ └── fork.cpp ├── Chapter_MUTEX │ ├── test1.cpp │ ├── test2.cpp │ ├── test3.cpp │ └── test4.cpp ├── Chapter_SIGNAL │ ├── test1.cpp │ └── test2.cpp └── Chapter_STATIC │ ├── inc │ └── mymath.h │ ├── lib │ └── libmymath.a │ ├── note.txt │ ├── src │ ├── add.cpp │ ├── add.o │ ├── sub.cpp │ └── sub.o │ └── test.cpp └── WHY_THEORY ├── CLASS ├── Makefile ├── main.why ├── queue.c ├── queue.h ├── sqrt.why ├── task_3.mlw ├── task_3_2.mlw ├── task_4_1.mlw ├── task_5_1.c ├── task_5_1.mlw ├── task_5_2.c ├── task_6_1.c └── task_6_2.c ├── TASK1 ├── task1.1 │ ├── task1.c │ ├── task1.pdf │ ├── task1.why │ ├── task1 │ │ ├── why3session.xml │ │ └── why3shapes.gz │ ├── task2.c │ ├── task2.pdf │ ├── task2.why │ └── task2 │ │ ├── why3session.xml │ │ ├── why3session.xml.bak │ │ ├── why3shapes.gz │ │ └── why3shapes.gz.bak ├── task1.2 │ ├── task.c │ ├── task.pdf │ ├── task.why │ └── task │ │ ├── why3session.xml │ │ └── why3shapes.gz └── task1.3 │ ├── task.c │ ├── task.pdf │ ├── task.why │ └── task │ ├── why3session.xml │ └── why3shapes.gz ├── TASK2 ├── task2.1 │ ├── task.mlw │ └── task │ │ ├── why3session.xml │ │ └── why3shapes.gz └── task2.2 │ ├── task.mlw │ └── task │ ├── why3session.xml │ └── why3shapes.gz ├── TASK3 ├── task3.1 │ └── task.mlw └── task3.2 │ └── graph.c └── TASK4 ├── Makefile ├── README.md ├── main.c ├── map.c ├── map.h └── maptypes.h /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "SimpleDataBase"] 2 | path = C++_CLASS_TEST/SimpleDataBase 3 | url = https://github.com/KCNyu/SimpleDataBase.git 4 | [submodule "Matrix"] 5 | path = C++_CLASS_TEST/Matrix 6 | url = https://github.com/KCNyu/Matrix 7 | [submodule "Linked_list"] 8 | path = C++_LECTURE/Linked_list 9 | url = https://github.com/KCNyu/Tree 10 | [submodule "Chapter_WEB"] 11 | path = UNIX_NETWORK/Chapter_WEB 12 | url = https://github.com/KCNyu/HttpWebServer 13 | [submodule "Shell"] 14 | path = C_UNIX/Chapter_SHELL 15 | url = https://github.com/KCNyu/Myshell 16 | -------------------------------------------------------------------------------- /C++_AIS/prac3.1/README.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | `pip install -r requirements.txt` 3 | 4 | # Run Tests 5 | `./test.sh` 6 | 7 | # Test Results 8 | Will be saved in `TestResults` directory. 9 | * 01-linear.dot, 01-linear.png 10 | * 02-bubblesort.dot, 02-branch.png 11 | * 03-primes.dot, 03-primes.png 12 | * 04-indirect.dot, 04-indirect.png 13 | * 05-switch.dot, 05-switch.png 14 | 15 | # Usage 16 | `Usage: python main.py ` -------------------------------------------------------------------------------- /C++_AIS/prac3.1/requirements.txt: -------------------------------------------------------------------------------- 1 | graphviz==0.20.1 2 | -------------------------------------------------------------------------------- /C++_AIS/prac3.2/README.md: -------------------------------------------------------------------------------- 1 | # Run Tests 2 | `./test.sh` 3 | 4 | # Test Results 5 | Will be saved in `TestResults` directory. 6 | * 01-copy.out.json 7 | * 02-calculate.out.json 8 | * 03-password.out.json 9 | * 04-functions.out.json 10 | * 05-encrypt.out.json 11 | 12 | # Usage 13 | `Usage: python main.py [file.json] [file.tests.json] [file.out.json]` -------------------------------------------------------------------------------- /C++_ALGEBRA/TEST1/1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C++_ALGEBRA/TEST1/1.zip -------------------------------------------------------------------------------- /C++_ALGEBRA/TEST2/2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C++_ALGEBRA/TEST2/2.zip -------------------------------------------------------------------------------- /C++_ALGEBRA/TEST2/task_2c.txt: -------------------------------------------------------------------------------- 1 | The runtime is 33 s -------------------------------------------------------------------------------- /C++_ALGEBRA/TEST3/3.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C++_ALGEBRA/TEST3/3.zip -------------------------------------------------------------------------------- /C++_CLASS_TEST/Dec_15/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "list.h" 3 | using namespace std; 4 | 5 | int main() { 6 | List l1,l2('a'), l3("abcabcabaa"), l4(l1), l5(l3); 7 | cout< 8 | #include 9 | using namespace std; 10 | class A{ 11 | public: 12 | static int x; 13 | void get_0() const; 14 | }; 15 | int A::x; 16 | int main () { 17 | const A a; 18 | a.x = 1; 19 | a.get_0(); 20 | return 0; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Dec_22/VVK.6.4.b.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:VVK.6.4.b.cpp 3 | * Author: KCN_yu 4 | * Createtime:Tue 22 Dec 2020 09:11:29 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | class A{ 11 | public: 12 | static const char a; 13 | static void f(){} 14 | }; 15 | const char A::a = '+'; 16 | int main () { 17 | A ob; 18 | A::f(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Dec_22/VVK.6.4.c.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:VVK.6.4.c.cpp 3 | * Author: KCN_yu 4 | * Createtime:Tue 22 Dec 2020 09:33:06 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | class A{ 11 | public: 12 | static void g(){} 13 | void h()const{} 14 | }; 15 | int main () { 16 | const A x; 17 | A::g(); 18 | x.h(); 19 | return 0; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Dec_8/K.2.1.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:K.2.1.cpp 3 | * Author: KCN_yu 4 | * Createtime:Sun 06 Dec 2020 08:06:24 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Dec_8/VVK.1.13.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:VVK.1.13.cpp 3 | * Author: KCN_yu 4 | * Createtime:Sun 06 Dec 2020 08:31:38 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | struct mystr { 12 | int a, b; 13 | private: mystr(const mystr &){} 14 | }; 15 | 16 | int i = sizeof(mystr); 17 | 18 | int f(mystr s) { 19 | return i; 20 | } 21 | int main(int argc, char *argv[]) 22 | { 23 | mystr s; 24 | cout << f(s) << endl; 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Dec_8/VVK.1.14.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:VVK.1.14.cpp 3 | * Author: KCN_yu 4 | * Createtime:Thu 10 Dec 2020 07:15:50 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | class smartstr 12 | { 13 | private: 14 | string s; 15 | public: 16 | smartstr(string t){ t = s; } 17 | }; 18 | 19 | int main(int argc, char *argv[]) 20 | { 21 | smartstr s1("hello"); 22 | //smartstr s2 = new smartstr[1]; 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Dec_8/t.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:t.cpp 3 | * Author: KCN_yu 4 | * Createtime:Fri 11 Dec 2020 01:02:53 AM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | int a = 100; 15 | //cin >> a; 16 | cout << a; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Jan_12/1.txt: -------------------------------------------------------------------------------- 1 | program 2 | var a, b: int; 3 | begin 4 | read(a); 5 | read(b); 6 | if (a=1) or (b=1) then write(1) 7 | else 8 | while a!=b do 9 | begin 10 | if (a>b) then a:=a-b 11 | else 12 | b:=b-a 13 | end; 14 | write(a) 15 | end@ 16 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Jan_12/2.a_b_c_d.txt: -------------------------------------------------------------------------------- 1 | program 2 | var a, b: char; 3 | begin 4 | read(a); 5 | b:='z'; 6 | 7 | if(b>a) then write(b); 8 | 9 | ; 10 | ;; ;; ; ;; 11 | ; ; 12 | 13 | repeat 14 | begin 15 | a:=a+1; 16 | write(a) 17 | end 18 | until a=b; 19 | 20 | if(a!=b) then else write(123456) 21 | end@ 22 | 23 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Jan_12/abcd.txt: -------------------------------------------------------------------------------- 1 | program 2 | var x, y: int; 3 | begin 4 | read(x); 5 | read(y);;;;; ;;;; 6 | ;; ; ; ; ; ;; 7 | ;;;; 8 | repeat 9 | begin 10 | x:=x+2; 11 | if x>y then else write(x) 12 | end 13 | until x>10; 14 | if x>y then write(y) 15 | end@ 16 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Jan_12/fibo.txt: -------------------------------------------------------------------------------- 1 | program 2 | var cur, prev, next, n: int; 3 | begin 4 | read(n); 5 | if (n=0) or (n=1) then write (n) 6 | else 7 | begin 8 | prev:=0; 9 | cur:=1; 10 | while n>1 do 11 | begin 12 | n:=n-1; 13 | next:=cur+prev; 14 | prev:=cur; 15 | cur:=next 16 | end; 17 | write(cur) 18 | end 19 | end@ 20 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Jan_12/t.txt: -------------------------------------------------------------------------------- 1 | program 2 | var a,b:int; 3 | begin 4 | a:=0; b:=1;; 5 | if a>b then else write(b) 6 | end@ 7 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Jan_7/temp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C++_CLASS_TEST/Jan_7/temp -------------------------------------------------------------------------------- /C++_CLASS_TEST/Koloc/fread.c: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:fread.c 3 | * Author: KCN_yu 4 | * Createtime:Wed 20 Jan 2021 06:46:42 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | float mas[1]; 13 | FILE *fp = fopen(argv[1],"r"); 14 | if(fp == NULL){ 15 | printf("ERROR!\n"); 16 | return 0; 17 | } 18 | while(fread(mas,sizeof(float),1,fp)) 19 | printf("%f\n",mas[0]); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Koloc/res.txt: -------------------------------------------------------------------------------- 1 | -1.000000, -0.000000, -3.000000, 1 2 | -0.777778, -0.395062, -3.395062, -1 3 | -0.555556, -0.691358, -3.691358, -1 4 | -0.333333, -0.888889, -3.888889, -1 5 | -0.111111, -0.987654, -3.987654, -1 6 | 0.111111, -0.987654, -3.987654, -1 7 | 0.333333, -0.888889, -3.888889, -1 8 | 0.555556, -0.691358, -3.691358, -1 9 | 0.777778, -0.395062, -3.395062, -1 10 | 1.000000, 0.000000, -3.000000, 1 11 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Koloc/test2.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:test2.cpp 3 | * Author: KCN_yu 4 | * Createtime:Wed 20 Jan 2021 03:55:12 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | void g(char* a,long double b){} 15 | void g(std::vector a,int b){} 16 | void g(std::list a, short b){} 17 | int main(int argc, char *argv[]) 18 | { 19 | g(std::vector(),1.2); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Koloc/test4.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:test4.cpp 3 | * Author: KCN_yu 4 | * Createtime:Wed 20 Jan 2021 04:18:50 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | class A{ 12 | public: 13 | void operator()(){} 14 | }; 15 | int main(int argc, char *argv[]) 16 | { 17 | A c; 18 | c(); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Koloc/test5.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:test5.cpp 3 | * Author: KCN_yu 4 | * Createtime:Wed 20 Jan 2021 04:21:06 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | class A{ 11 | public: 12 | virtual void f() const { cout << "A::f() ";} 13 | }; 14 | class B: public A{ 15 | public: 16 | void f() const { cout << "B::f() "; } 17 | }; 18 | int main(int argc, char *argv[]) 19 | { 20 | const A& a = B(); 21 | a.A::f(); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Koloc/test6.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:test6.cpp 3 | * Author: KCN_yu 4 | * Createtime:Wed 20 Jan 2021 04:27:29 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | class C{ 12 | public: 13 | C(){ cout << 'a'; } 14 | ~C(){ cout << 'b'; } 15 | void operator=(const C&a){ cout << 'c'; } 16 | }; 17 | int main(int argc, char *argv[]) 18 | { 19 | C a; 20 | cout <<'d'; 21 | C b(a); 22 | b = a; 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Koloc/test7.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:test7.cpp 3 | * Author: KCN_yu 4 | * Createtime:Wed 20 Jan 2021 04:30:21 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | void f(int i){ cout << 1;} 12 | void f(long l){ cout << 2;} 13 | template 14 | void f(T t){ cout << 3;} 15 | int main(int argc, char *argv[]) 16 | { 17 | short s = 1; 18 | f(s); 19 | f(1L); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Koloc/test8.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:test8.cpp 3 | * Author: KCN_yu 4 | * Createtime:Wed 20 Jan 2021 04:31:37 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | #include 10 | using namespace std; 11 | int main(int argc, char *argv[]) 12 | { 13 | list l; 14 | for( list ::iterator p = l.begin(); p!=l.end(); p++) { cout << *p << endl; } 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Shape/makefile: -------------------------------------------------------------------------------- 1 | Shape: main.o Shape.o 2 | g++ -o Shape main.o Shape.o 3 | main.o: main.cpp Shape.h 4 | g++ -c main.cpp 5 | Shape.o: Shape.cpp Shape.h 6 | g++ -c Shape.cpp 7 | clean: 8 | rm *.o Shape 9 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/Table.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C++_CLASS_TEST/Table.c -------------------------------------------------------------------------------- /C++_CLASS_TEST/Table.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C++_CLASS_TEST/Table.h -------------------------------------------------------------------------------- /C++_CLASS_TEST/exam/test6.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:test6.cpp 3 | * Author: KCN_yu 4 | * Createtime:Wed 30 Dec 2020 04:36:56 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | void f(const char* s){} 11 | void f(int a = 0, int b = 0){} 12 | int main(int argc, char *argv[]) 13 | { 14 | f ("string"); 15 | f (200); 16 | f ('+', 300); f (); 17 | return 0; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/exam/test7.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | using namespace std; 4 | class A { 5 | public: A () { cout << 1 << endl; } 6 | }; 7 | class B: public A { 8 | public: B (int n) { try { if (n == 0) throw *this; 9 | if (n > 11) throw 11; } 10 | catch (int) { cout << 2 << endl; } 11 | catch (B&) { cout << 3 << endl; throw; } 12 | cout << 4 << endl; } 13 | B (B&) {cout << 5 << endl;} 14 | ~B () {cout << 6 << endl;} 15 | }; 16 | int main() { try { B b(0); B c (3); } 17 | catch (...) { cout << 7 << endl; } 18 | cout << 8 << endl; 19 | } 20 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/exam/test8.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:test8.cpp 3 | * Author: KCN_yu 4 | * Createtime:Wed 30 Dec 2020 04:41:11 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | class Y { 12 | public: 13 | static void g () {cout << "g\n";} 14 | void f () const {cout << "f\n";} 15 | }; 16 | int main () { 17 | const Y a; 18 | Y::g(); 19 | a.f(); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C++_CLASS_TEST/test11.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:test11.cpp 3 | * Author: KCN_yu 4 | * Createtime:Thu 17 Dec 2020 07:08:17 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | using namespace std; 10 | 11 | struct S { 12 | virtual void f() const = 0; 13 | virtual ~S() {} 14 | }; 15 | struct A { 16 | S s; 17 | int i; 18 | }; 19 | -------------------------------------------------------------------------------- /C++_LECTURE/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "unordered_map": "cpp", 4 | "ostream": "cpp" 5 | } 6 | } -------------------------------------------------------------------------------- /C++_LECTURE/Algorithms/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "iostream": "cpp", 4 | "ostream": "cpp" 5 | } 6 | } -------------------------------------------------------------------------------- /C++_LECTURE/Algorithms/IntPartition.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXLENTH 20 3 | using namespace std; 4 | 5 | int main() { 6 | const int len = MAXLENTH; 7 | long num[len + 1] = { 1 }; 8 | 9 | for (int i = 1; i <= len; ++i) 10 | for (int j = i; j <= len; ++j) 11 | num[j] += num[j - i]; 12 | 13 | for (int i = 0; i <= len; i++) 14 | cout << i << " " << num[i] << endl; 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C++_LECTURE/Algorithms/temp.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:temp.cpp 3 | * Author: KCN_yu 4 | * Createtime:Tue 06 Apr 2021 06:22:56 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | using namespace std; 9 | 10 | int SumDel(int N, int i){ 11 | if(N <= i) return N; 12 | if(N%i == 0) return i+SumDel(N/i,i); 13 | else return SumDel(N,i+1); 14 | } 15 | int S(int N){ 16 | return SumDel(N,2); 17 | } 18 | int main(int argc, char *argv[]) 19 | { 20 | cout << S(1164724681) << endl; 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /C++_LECTURE/Combinaaatorics/temp.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: temp.cpp 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 18 Nov 2019 07:15:03 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | using namespace std; 10 | int main() 11 | { 12 | int a = 1, b = 2; 13 | swap(a,a++); 14 | printf("a = %d\nb = %d\n",a,b); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C++_LECTURE/Student_scores/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C++_LECTURE/Student_scores/main -------------------------------------------------------------------------------- /C++_LECTURE/Student_scores/main.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C++_LECTURE/Student_scores/main.o -------------------------------------------------------------------------------- /C++_LECTURE/Student_scores/students.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C++_LECTURE/Student_scores/students.o -------------------------------------------------------------------------------- /C++_LECTURE/Student_scores/test2.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test2.cpp 3 | > Author: 4 | > Mail: 5 | > Created Time: Fri 11 Oct 2019 12:11:34 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | using namespace std; 10 | 11 | class Students{ 12 | public: 13 | ~Students(){ 14 | cout << "Memory has been cleaned. Good bye." 15 | << endl; 16 | } 17 | }; 18 | 19 | int main(){ 20 | Students *student = new Students; 21 | delete student; 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /C++_LECTURE/TSP/input.txt: -------------------------------------------------------------------------------- 1 | 32767 3 93 13 33 9 2 | 4 32767 77 42 21 16 3 | 45 17 32767 36 16 28 4 | 39 90 80 32767 56 7 5 | 28 46 88 33 32767 25 6 | 3 88 18 46 92 32767 -------------------------------------------------------------------------------- /C++_LECTURE/TSP/input1.txt: -------------------------------------------------------------------------------- 1 | 32767 25 40 31 27 2 | 5 32767 17 30 25 3 | 19 15 32767 6 1 4 | 9 50 24 32767 6 5 | 22 8 7 10 32767 6 | -------------------------------------------------------------------------------- /C++_LIBRARY/LogUtils.cc: -------------------------------------------------------------------------------- 1 | #include "LogUtils.h" -------------------------------------------------------------------------------- /C++_PARALLEL/Chapter_Class/MPI1Proc1.cpp: -------------------------------------------------------------------------------- 1 | #include "pt4.h" 2 | #include "mpi.h" 3 | #include 4 | void Solve() 5 | { 6 | Task("MPI1Proc1"); 7 | int flag; 8 | MPI_Initialized(&flag); 9 | if (flag == 0) 10 | return; 11 | int rank, size; 12 | MPI_Comm_size(MPI_COMM_WORLD, &size); 13 | MPI_Comm_rank(MPI_COMM_WORLD, &rank); 14 | PutN(rank); 15 | } 16 | -------------------------------------------------------------------------------- /C++_PARALLEL/Chapter_Class/MPI2Send19.cpp: -------------------------------------------------------------------------------- 1 | #include "pt4.h" 2 | #include "mpi.h" 3 | void Solve() 4 | { 5 | Task("MPI2Send19"); 6 | int flag; 7 | MPI_Initialized(&flag); 8 | if (flag == 0) 9 | return; 10 | int rank, size; 11 | MPI_Comm_size(MPI_COMM_WORLD, &size); 12 | MPI_Comm_rank(MPI_COMM_WORLD, &rank); 13 | double n, res; 14 | pt >> n; 15 | MPI_Sendrecv_replace(&n, 1, MPI_DOUBLE, size-rank-1, 0, size-rank-1, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); 16 | pt << n; 17 | } 18 | -------------------------------------------------------------------------------- /C++_PARALLEL/Chapter_Class/MPI3Coll8.cpp: -------------------------------------------------------------------------------- 1 | #include "pt4.h" 2 | #include "mpi.h" 3 | void Solve() 4 | { 5 | Task("MPI3Coll8"); 6 | int flag; 7 | MPI_Initialized(&flag); 8 | if (flag == 0) 9 | return; 10 | int rank, size; 11 | MPI_Comm_size(MPI_COMM_WORLD, &size); 12 | MPI_Comm_rank(MPI_COMM_WORLD, &rank); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /C++_PARALLEL/Chapter_Class/MPIGravit4.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C++_PARALLEL/Chapter_Class/MPIGravit4.cpp -------------------------------------------------------------------------------- /C++_PARALLEL/Chapter_Tutorial/test1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | #pragma omp parallel 7 | { 8 | cout << "All thread run this" << endl; 9 | #pragma omp sections 10 | { 11 | #pragma omp section 12 | { 13 | cout << "this excute in parallel" << endl; 14 | } 15 | #pragma omp section 16 | { 17 | cout << "Sequential statement 1" << endl; 18 | cout << "This always excute after statement 1" << endl; 19 | } 20 | #pragma omp section 21 | { 22 | cout << "this also excute in prallel" << endl; 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /C++_PARALLEL/Chapter_Tutorial/test2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include // NEW ADD 3 | 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | 9 | int sum = 0; 10 | #pragma omp parallel for num_threads(32) reduction(+:sum) 11 | for (int i = 0; i < 100; i++) 12 | { 13 | sum += i; 14 | } 15 | 16 | cout << sum << endl; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /C++_PARALLEL/Chapter_Tutorial/test3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include // NEW ADD 3 | 4 | using namespace std; 5 | 6 | #define DEFINE_idx auto idx = omp_get_thread_num(); 7 | #define _ROWS (omp_get_num_threads()) 8 | 9 | int main() 10 | { 11 | #pragma omp parallel for num_threads(3) 12 | for(int i = 0; i < 10; i++) 13 | { 14 | DEFINE_idx; 15 | printf("- idx is %d, i is %d, total thread num is %d\n", idx, i, _ROWS); 16 | } 17 | } -------------------------------------------------------------------------------- /C++_SC/task1/program_213.c: -------------------------------------------------------------------------------- 1 | for(i = 2; i <= n+1; ++i){ 2 | for(j = 2; j <= m+1; ++j){ 3 | C[i][j] = C[i][j + 1] + D[i][j]; 4 | } 5 | } 6 | 7 | for(i = 2; i <= n+1; ++i){ 8 | #pragma omp parallel for 9 | for(j = 2; j <= m+1; ++j){ 10 | B[i][j] = B[i - 1][j] + C[2][2]; 11 | } 12 | } 13 | #pragma omp parallel for 14 | for(i = 2; i <= n+1; ++i){ 15 | for(j = 2; j <= m+1; ++j){ 16 | #pragma omp parallel for 17 | for(k = 1; k <= n; ++k){ 18 | A[i][j][k] = A[i][j][k] + A[i][j - 1][1] + C[i][m + 1]; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /C++_SC/task2/include/solver.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "task.hpp" 4 | 5 | class Solver 6 | { 7 | protected: 8 | Task task; 9 | 10 | public: 11 | Solver(Task task) : task(task) {} 12 | virtual void run() = 0; 13 | virtual ~Solver() {} 14 | }; -------------------------------------------------------------------------------- /C++_SC/task2/scripts/download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | USER="edu-cmc-skmodel23-628-06" 4 | HOST="polus.hpc.cs.msu.ru" 5 | 6 | scp $USER@$HOST:~/task2/task2_L1/task_N128.json task_N128.json 7 | scp $USER@$HOST:~/task2/task2_L2/task_N256.json task_N256.json 8 | -------------------------------------------------------------------------------- /C++_SC/task2/scripts/upload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | USER="edu-cmc-skmodel23-628-06" 4 | HOST="polus.hpc.cs.msu.ru" 5 | 6 | cd .. 7 | 8 | rm task2.zip 9 | 10 | zip -r task2.zip task2/include task2/main.cpp task2/Makefile task2/scripts 11 | 12 | scp task2.zip $USER@$HOST:~ 13 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test1.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | printf("hello world你好吗"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test10.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char a = 70, b = 105, c = 115, d = 104, e = 67; 5 | printf("%c%c%c%c%c\n",a,b,c,d,e); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test11.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | unsigned char height = 170; 5 | printf("is%d\n",height); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test12.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char a[6] = {'F','i','S','h','c'}; 5 | printf("%s\n",a); 6 | printf("hello world!\n"); 7 | return ; 8 | } 9 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test13.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | int i, j, k; 6 | 7 | i = 1 + 2; 8 | j = 1 + 2 * 3; 9 | k = i + j + -1 + pow(2,3); 10 | 11 | printf("i = %d\n",i); 12 | printf("j = %d\n",j); 13 | printf("k = %d\n",k); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test14.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | printf("整型输出:%d\n",1 + (int)2.0); 5 | printf("浮点型输出:%f\n",1 + 2.0); 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test2.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a; 5 | char b; 6 | float c; 7 | double d; 8 | 9 | a = 520; 10 | b = 'f'; 11 | c = 3.14; 12 | d = 3.1415926535; 13 | 14 | printf("大家%d\n",a); 15 | printf("i love you%c\n",b); 16 | printf("圆周率是:%.2f\n",c); 17 | printf("精确到小数点后九位的圆周率是:%.9f\n",d); 18 | 19 | return 0; 20 | } 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define URL "www.baidu.com" 4 | #define NAME "搜索引擎" 5 | #define BOSS "李彦宏" 6 | #define YEAR 2008 7 | #define MONTH 5 8 | #define DAY 20 9 | 10 | int main() 11 | { 12 | printf("%s成立于%d年%d月%d日\n",NAME,YEAR,MONTH,DAY); 13 | printf("%s是%s创立的\n",NAME,BOSS); 14 | printf("%s的域名是%s\n",NAME,URL); 15 | return 0; 16 | 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test4.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i; 5 | char j; 6 | float k; 7 | 8 | i = 123; 9 | j = 'c'; 10 | k = 3.14; 11 | 12 | printf("size of int is %d\n",sizeof(int)); 13 | printf("size of i is %d\n",sizeof(i)); 14 | printf("size of char is %d\n",sizeof(char)); 15 | printf("size of j is %d\n",sizeof(j)); 16 | printf("size of float is %d\n",sizeof(float)); 17 | printf("size of k is %d\n",sizeof(k)); 18 | return 0; 19 | 20 | } 21 | 22 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test5.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | printf("int = %d\n",sizeof(int)); 5 | printf("short int = %d\n",sizeof(short)); 6 | printf("long int = %d\n",sizeof(long)); 7 | printf("long long int = %d\n",sizeof(long long)); 8 | printf("char = %d\n",sizeof(char)); 9 | printf("_Bool = %d\n",sizeof(_Bool)); 10 | printf("float = %d\n",sizeof(float)); 11 | printf("double = %d\n",sizeof(double)); 12 | printf("long double = %d\n",sizeof(long double)); 13 | 14 | return 0; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test6.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | short i; 6 | unsigned short j; 7 | 8 | i = -1; 9 | j = -1; 10 | 11 | printf("%d\n",i); 12 | printf("%d\n",j); 13 | 14 | return 0; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test7.c: -------------------------------------------------------------------------------- 1 | #include ; 2 | #include 3 | int main() 4 | { 5 | unsigned int result; 6 | result = pow(2,32) - 1; 7 | printf("result = %u\n",result); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test8.c: -------------------------------------------------------------------------------- 1 | #include : 2 | #include ; 3 | int main() 4 | { 5 | int result = pow(2,31) - 1; 6 | printf("result = %d\n",result); 7 | return 0; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /C_BASIC/Chapter1/test9.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char a = 'C'; 5 | printf("%c = %d\n",a,a); 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test1.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a = 5, b = 3; 5 | 6 | printf("%d\n", 1 < 2); 7 | printf("%d\n", a > b); 8 | printf("%d\n", a <= 1 + b); 9 | printf("%d\n", 'a' + 'b' <= 'c'); 10 | printf("%d\n", (a=3) > (b=5)); 11 | 12 | return 0; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test10.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char ch; 5 | 6 | printf("how points are you?\n"); 7 | scanf("%c",&ch); 8 | 9 | switch(ch) 10 | { 11 | case 'A': printf("your marks are higher than 90!\n");break; 12 | case 'B': printf("your marks are between 80 and 90!\n");break; 13 | case 'C': printf("your marks are between 70 and 80!\n");break; 14 | case 'D': printf("your marks are between 60 and 70!\n");break; 15 | case 'E': printf("your marks are lower than 60!\n");break; 16 | default: printf("please write former marks!\n"); 17 | } 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test11.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b; 5 | printf("please input 2 numbers"); 6 | scanf("%d %d",&a,&b); 7 | 8 | if (a != b) 9 | { 10 | if (a > b) 11 | { 12 | printf("%d > %d",a,b); 13 | } 14 | else 15 | { 16 | printf("%d < %d",a,b); 17 | } 18 | 19 | } 20 | else 21 | { 22 | printf("%d = %d",a,b); 23 | } 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test12.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char isRain, isFree; 5 | 6 | printf("Free?(Y/N)"); 7 | scanf("%c",&isFree); 8 | 9 | getchar(); 10 | 11 | printf("Rain?(Y/N)"); 12 | scanf("%c",&isRain); 13 | 14 | if (isFree == 'Y' && isRain == 'Y') 15 | { 16 | printf("please bring umbrella!\n"); 17 | } 18 | else if (isFree == 'N') 19 | { 20 | printf("get out!\n"); 21 | } 22 | else 23 | { 24 | printf("good luck!\n"); 25 | 26 | } 27 | 28 | return 0; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test13.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char hasBF; 5 | 6 | printf("do you have boyfriend?(Y/N)"); 7 | scanf("%c",&hasBF); 8 | 9 | if (hasBF == 'Y') 10 | { 11 | printf("good job!\n"); 12 | } 13 | else 14 | { 15 | printf("i love you!\n"); 16 | } 17 | 18 | return 0; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test14.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i = 1, sum = 0; 5 | while (i <= 100) 6 | { 7 | sum = sum + i; 8 | i = i + 1; 9 | } 10 | printf("sum = %d\n",sum); 11 | 12 | return 0; 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test15.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int count = 0; 5 | printf("please write a sentence!"); 6 | while (getchar() != '\n') 7 | { 8 | count = count + 1; 9 | } 10 | printf("you have written %d words!\n",count); 11 | 12 | return 0; 13 | 14 | } 15 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test16.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i = 1, sum = 0; 5 | do 6 | { 7 | sum = sum + i; 8 | i = i + 1; 9 | }while (i <= 100); 10 | printf("sum = %d\n",sum); 11 | 12 | return 0; 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test17.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int count; 5 | for (count = 0; count < 10; count++) 6 | { 7 | printf("FishC!\n"); 8 | } 9 | 10 | return 0; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test18.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i, num; 5 | _Bool flag = 1; 6 | 7 | printf("please write a number!"); 8 | scanf("%d",&num); 9 | 10 | for ( i = 2; i <= num / 2; i++) 11 | { 12 | if (num % i == 0) 13 | { 14 | flag = 0; 15 | } 16 | } 17 | if (flag) 18 | { 19 | printf("%d is a prime number!\n",num); 20 | } 21 | else 22 | { 23 | printf("%d is a composite number!\n",num); 24 | } 25 | 26 | return 0; 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test19.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i , j; 5 | for (i = 0, j = 10 ; i < j; i++, j--) 6 | { 7 | printf("%d\n",i); 8 | } 9 | 10 | return 0; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test2.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a = 5, b = 3; 5 | 6 | printf("%d\n", 3 > 1 && 1 < 2); 7 | printf("%d\n", 3 + 1 || 2 == 0); 8 | printf("%d\n", !(a + b) ); 9 | printf("%d\n", !0 + 1 < 1 || !(3 + 4)); 10 | printf("%d\n", 'a' - 'b' && 'c'); 11 | 12 | return 0; 13 | 14 | } 15 | 16 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test20.c: -------------------------------------------------------------------------------- 1 | #include 2 | -std =c99 3 | int main() 4 | { 5 | for (int i=0,int j =10; i < j; i++, j--) 6 | { 7 | printf("%d\n",i); 8 | } 9 | 10 | return 0; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test21.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i , j; 5 | for (i = 0, j = 10 ; i < j; i++, j--) 6 | { 7 | printf("%d\n",i); 8 | } 9 | printf("%d,%d\n",i,j); 10 | return 0; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test22.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,j; 5 | for (i = 0; i < 3;i++) 6 | { 7 | for (j = 0; j < 3 ; j++) 8 | { 9 | printf("i = %d, j = %d\n", i,j); 10 | } 11 | } 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test23.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i ,j; 5 | for (i = 1; i <= 9; i++) 6 | { 7 | for (j = 1; j<= i; j++) 8 | { 9 | printf("%d * %d = %-2d",i,j,i * j); 10 | } 11 | putchar('\n'); 12 | } 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test24.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | long long i, num; 5 | _Bool flag = 1; 6 | 7 | printf("please write a number!\n"); 8 | scanf("%lld",&num); 9 | 10 | for (i = 2; i < num / 2; i ++) 11 | { 12 | if (num % i == 0) 13 | { 14 | flag = 0; 15 | break; 16 | } 17 | 18 | } 19 | if (flag) 20 | { 21 | printf("%lld is a primer number!",num); 22 | } 23 | else 24 | { 25 | printf("%lld is not a primer number!",num); 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test25.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i , j; 5 | for (i = 0; i < 10; i++) 6 | { 7 | for (j = 0; j < 10; j++) 8 | { 9 | if (j == 3) 10 | { 11 | break; 12 | } 13 | } 14 | if (j == 3) 15 | { 16 | break; 17 | } 18 | } 19 | printf("%d\n%d\n",i,j); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test26.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int ch; 5 | while ((ch = getchar()) != '\n') 6 | { 7 | if (ch == 'C') 8 | { 9 | continue; 10 | } 11 | putchar(ch); 12 | } 13 | putchar('\n'); 14 | return 0; 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test27.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i; 5 | for(i = 0; i < 100; i++ ) 6 | { 7 | if(i % 2) 8 | { 9 | continue; 10 | } 11 | printf("%d\n",i); 12 | } 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test28.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i; 5 | i = 0; 6 | while( i < 100 ) 7 | { 8 | if(i % 2) 9 | { 10 | continue; 11 | } 12 | i++; 13 | printf("%d\n",i); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test29.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i =5, j; 5 | 6 | j = ++i; 7 | printf("i = %d , j = %d\n",i,j); 8 | 9 | i = 5; 10 | j = i++; 11 | printf("i = %d , j = %d\n",i,j); 12 | 13 | return 0; 14 | } 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test3.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a = 3, b = 3; 5 | 6 | (a = 0) && (b = 5); 7 | printf("a = %d, b = %d\n", a, b); 8 | 9 | (a = 1) || (b = 5); 10 | printf("a = %d, b = %d", a,b); 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test30.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a, b, c; 5 | a =( b = 3,(c = b + 4) + 5); 6 | printf("a = %d, b = %d, c = %d\n",a, b, c); 7 | 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test31.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i = 5; 5 | while (i++) 6 | { 7 | if (i > 10) 8 | { 9 | goto Label; 10 | } 11 | } 12 | Label: printf("here, i = %d\n",i); 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test32.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int result, i; 5 | result = 0; 6 | i = 0; 7 | while (i <= 100) 8 | { 9 | result += i; 10 | i++; 11 | } 12 | printf("result = %d\n i = %d\n",i,result); 13 | return 0; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test4.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i; 5 | 6 | printf("how old are you?"); 7 | scanf("%d", &i); 8 | 9 | if (i >= 18) 10 | { 11 | printf("left!\n"); 12 | } 13 | 14 | return 0; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test5.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i; 5 | 6 | printf("how old are you?\n"); 7 | scanf("%d", &i); 8 | 9 | if (i >= 18) 10 | printf("left!\n"); 11 | return 0 ; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test6.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i ; 5 | printf("how old are you?\n"); 6 | scanf("%d",&i); 7 | 8 | if (i >= 18) 9 | { 10 | printf("left!\n"); 11 | printf("thank you!\n"); 12 | } 13 | 14 | return 0; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test7.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i; 5 | printf("how old are you?\n"); 6 | scanf("%d",&i); 7 | 8 | if (i >= 18) 9 | { 10 | printf("left!\n"); 11 | } 12 | 13 | else 14 | { 15 | printf("get out!\n"); 16 | } 17 | 18 | return 0; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test8.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i; 5 | printf("how many points are you?\n"); 6 | scanf("%d",&i); 7 | 8 | if (i >= 90) 9 | { 10 | printf("A\n"); 11 | } 12 | else if(i >= 80 && i < 90) 13 | { 14 | printf("B\n"); 15 | } 16 | else if (i >= 70 && i < 80) 17 | { 18 | printf("C\n"); 19 | } 20 | else if (i >= 60 && i < 70) 21 | { 22 | printf("D\n"); 23 | } 24 | else 25 | { 26 | printf("E\n"); 27 | } 28 | 29 | return 0; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /C_BASIC/Chapter2/test9.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char ch; 5 | 6 | printf("how points are you?\n"); 7 | scanf("%c",&ch); 8 | 9 | switch(ch) 10 | { 11 | case 'A': printf("your marks are higher than 90!\n"); 12 | case 'B': printf("your marks are between 80 and 90!\n"); 13 | case 'C': printf("your marks are between 70 and 80!\n"); 14 | case 'D': printf("your marks are between 60 and 70!\n"); 15 | case 'E': printf("your marks are lower than 60!\n"); 16 | default: printf("please write former marks!\n"); 17 | } 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /C_BASIC/Chapter3/test1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define NUM 10 3 | int main() 4 | { 5 | int s[NUM]; 6 | int i , sum = 0; 7 | for (i = 0; i < NUM; i++) 8 | { 9 | printf("please write the %d student's mark: ", i + 1 ); 10 | scanf("%d",&s[i]); 11 | sum += s[i]; 12 | } 13 | printf("the average is: %.2f\n",(double)sum / NUM); 14 | return 0; 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /C_BASIC/Chapter3/test2.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int n, i; 5 | printf("please write the number of the string: "); 6 | scanf("%d",&n); 7 | char a[n + 1]; 8 | printf("please write the string: "); 9 | getchar(); 10 | for (i = 0; i < n; i++) 11 | { 12 | scanf("%c", &a[i]); 13 | } 14 | a[n] = '\0'; 15 | printf("the string which you write is: %s\n",a); 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /C_BASIC/Chapter3/test3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | char str[] = "i love you!"; 6 | printf("sizeof str = %d\n",sizeof(str)); 7 | printf("strlen str = %u\n",strlen(str)); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /C_BASIC/Chapter3/test4.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | char str1[] = "Original String"; 6 | char str2[] = "New String"; 7 | char str3[100]; 8 | strcpy(str1, str2); 9 | strcpy(str3, "Copy Successful"); 10 | printf("str1: %s\n",str1); 11 | printf("str2: %s\n",str2); 12 | printf("str3: %s\n",str3); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /C_BASIC/Chapter3/test5.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | char str1[] = "To be or not to ge"; 6 | char str2[40]; 7 | strncpy(str2,str1,5); 8 | str2[5] = '\0'; 9 | printf("%s\n",str2); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /C_BASIC/Chapter3/test6.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | char str1[] = "I love"; 6 | char str2[] = "you!"; 7 | strcat(str1, " "); 8 | strcat(str1, str2); 9 | printf("str1: %s\n",str1); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /C_BASIC/Chapter3/test7.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | char str1[] = "i love you!"; 6 | char str2[] = "i love you!"; 7 | if (!strcmp (str1,str2)) 8 | { 9 | printf("the same!\n"); 10 | } 11 | else 12 | { 13 | printf("not the same!\n"); 14 | } 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /C_BASIC/Chapter3/test8.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int b[4][5] = { 5 | {80, 92, 85, 86, 99}, 6 | {78, 65, 89, 70, 99}, 7 | {67, 78, 76, 89, 99}, 8 | {88, 68, 98, 90, 99} 9 | 10 | }; 11 | int i, j; 12 | for (i = 0; i < 4; i++) 13 | { 14 | for (j = 0; j < 5; j++) 15 | { 16 | printf("%d ",b[i][j]); 17 | 18 | } 19 | printf("\n"); 20 | 21 | } 22 | return 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test1.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char a = 'F'; 5 | int f = 123; 6 | char *pa = &a; 7 | int *pf = &f; 8 | 9 | printf("a = %c\n", *pa); 10 | printf("f = %d\n", *pf); 11 | 12 | *pa = 'c'; 13 | *pf = *pf + 1; 14 | printf("now, a = %c\n", *pa); 15 | printf("now, f = %d\n", *pf); 16 | 17 | printf("sizeof pa = %d\n", sizeof(pa)); 18 | printf("sizeof pa = %d\n", sizeof(pf)); 19 | 20 | printf("the addr of a is: %p\n", pa); 21 | printf("the addr of f is: %p\n", pf); 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test10.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char *p1[3] = 5 | { 6 | "a-1", 7 | "b-2", 8 | "c-3" 9 | }; 10 | int i; 11 | for (i = 0; i < 3; i++) 12 | printf("%s\n",p1[i]); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test11.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int temp[5] = {1,2,3,4,5}; 5 | int (*p2)[5] = &temp; 6 | int i; 7 | for(i = 0; i < 5; i++) 8 | { 9 | printf("%d\n",*(*p2 + i)); 10 | } 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test15.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int array[4][5] = {0}; 5 | printf("sizeof int : %ld\n",sizeof(int)); 6 | printf("array: %p\n",array); 7 | printf("array+1: %p\n",array + 1); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test17.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test17.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 16 Oct 2019 08:59:51 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main() 10 | { 11 | int array[2][3] = {{0,1,2},{3,4,5}}; 12 | int (*p)[3] = array; 13 | 14 | printf("*(*p+1): %d\n",*(*p+1)); 15 | printf("array+1 = %p\n",array+1); 16 | printf("*(*array+1) = %d\n",*(*array+1)); 17 | printf("array[0][1] = %d\n",array[0][1]); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test19.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test19.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 16 Oct 2019 10:01:14 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main() 10 | { 11 | int num = 1024; 12 | int *pi = # 13 | char *ps = "FishC"; 14 | void *pv; 15 | 16 | pv = pi; 17 | printf("pi:%p, pv:%p\n",pi,pv); 18 | 19 | pv = ps; 20 | printf("ps:%p, pv:%p\n",ps,pv); 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test2.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a; 5 | int *p = &a; 6 | printf("please write a number: "); 7 | scanf("%d",&a); 8 | printf("a = %d\n",a); 9 | 10 | printf("please write a number again: "); 11 | scanf("%d",p); 12 | printf("a = %d\n",a); 13 | 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test3.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char str[128]; 5 | printf("please input the website: "); 6 | scanf("%s",str); 7 | printf("the website is %s\n",str); 8 | printf("str addr = %p\n",str); 9 | printf("str addr = %p\n",&str[0]); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test4.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char a[] = "Fishc"; 5 | int b[5] = {1, 2, 3, 4, 5}; 6 | float c[5] = {1.1, 2.2, 3.3, 4.4, 5.5}; 7 | double d[5] = {1.1, 2.2, 3.3, 4.4, 5.5}; 8 | 9 | printf("a[0] -> %p, a[1] -> %p, a[2] -> %p\n",&a[0],&a[1],&a[2]); 10 | printf("b[0] -> %p, b[1] -> %p, b[2] -> %p\n",&b[0],&b[1],&b[2]); 11 | printf("c[0] -> %p, c[1] -> %p, c[2] -> %p\n",&c[0],&c[1],&c[2]); 12 | printf("d[0] -> %p, d[1] -> %p, d[2] -> %p\n",&d[0],&d[1],&d[2]); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test5.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char a[] = "FishC"; 5 | char *p = a; 6 | printf("*p = %c, *(p+1) = %c, *(p+2) = %c\n",*p,*(p+1),*(p+2)); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test6.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a[] = {1, 2, 3, 4, 5}; 5 | int *p = a; 6 | printf("p -> %p, p+1 -> %p, p+2 -> %p\n",p,(p+1),(p+2)); 7 | printf("*p = %d, *(p+1) = %d, *(p+2) = %d\n",*p,*(p+1),*(p+2)); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test7.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | char *str = "i love fish.com!"; 6 | int i, length; 7 | 8 | length = strlen(str); 9 | 10 | for (i = 0; i < length; i++) 11 | { 12 | printf("%c",str[i]); 13 | } 14 | printf("\n"); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test8.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char str[] = "i love you!"; 5 | char *target = str; 6 | int count = 0; 7 | 8 | while(*target++ != '\0') 9 | { 10 | count++; 11 | } 12 | printf("count = %d\n",count); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_BASIC/Chapter4/test9.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a = 1; 5 | int b = 2; 6 | int c = 3; 7 | int d = 4; 8 | int e = 5; 9 | int *p1[5] = {&a, &b, &c, &d, &e}; 10 | int i; 11 | 12 | for (i = 0; i < 5 ; i++) 13 | { 14 | printf("%d\n",*p1[i]); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Array/Eratosthenes.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int n,i,j; 5 | scanf("%d",&n); 6 | int A[n],P[n]; 7 | for(i = 0; i < n; i++) 8 | A[i] = 1; 9 | for(i = 2; i < n; i++) 10 | for(j = 2*i; j < n; j += i) 11 | A[j] = 0; 12 | int k = 0; 13 | for(i = 2; i < n; i++){ 14 | if(A[i]){ 15 | P[k] = i; 16 | k++; 17 | } 18 | } 19 | for(i = 0; i < k; i++){ 20 | if((P[i]+2) == P[i+1]){ 21 | printf("%d %d\n",P[i],P[i+1]); 22 | } 23 | } 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Array/test11.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #define N 10 5 | int main() 6 | { 7 | int i,A[N], count_0 = 0; 8 | srand(time(NULL)); 9 | for(i = 0; i < N; i++) 10 | A[i] = rand()%2; 11 | for(i = 0; i < N; i++) 12 | printf("%d ",A[i]); 13 | printf("\n"); 14 | for(i = 0; i < N; i++) 15 | { 16 | if(A[i] == 0) 17 | count_0++; 18 | } 19 | for(i = 0; i < N; i++) 20 | { 21 | if(i < count_0) 22 | A[i] = 0; 23 | else 24 | A[i] = 1; 25 | } 26 | for(i = 0; i < N; i++) 27 | printf("%d ",A[i]); 28 | printf("\n"); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Array/test2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #define N 10 5 | int main() 6 | { 7 | int i,A[N],flag = 0; 8 | srand(time(NULL)); 9 | for(i = 0; i < N; i++) 10 | A[i] = rand()%10; 11 | for(i = 0; i < N; i++) 12 | printf("%d ",A[i]); 13 | printf("\n"); 14 | for(i = 0; i < N; i++) 15 | { 16 | if(A[i] > A[1] && A[i] < A[N-1]) 17 | { 18 | printf("A[%d] = %d\n",i,A[i]); 19 | flag = 1; 20 | break; 21 | } 22 | } 23 | if(flag != 1) 24 | printf("don't exist this element\n"); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Chapter1/test1.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | const int a = 10.0D; 5 | const int b = 1E-6; 6 | const int c = 0x1A15.1p1; 7 | const float d = 0.E-6; 8 | 9 | printf("%f\n",d); 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Chapter1/test11.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,sum1 = 0,sum2 = 0; 5 | for(i = 1; i <= 100; i++) 6 | { 7 | if(i%2 == 0) 8 | sum2 += i; 9 | else 10 | sum1 += i; 11 | } 12 | printf("sum1 = %d\nsum2 = %d\n",sum1,sum2); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Chapter1/test12.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i = 12; 5 | while(i <= 100) 6 | { 7 | printf("%d ",i); 8 | i += 3; 9 | } 10 | printf("\n"); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Chapter1/test13.c: -------------------------------------------------------------------------------- 1 | #include 2 | int gcd(int a, int b) 3 | { 4 | while(a != 0) 5 | { 6 | a = a % b; 7 | if(a == 0) 8 | return b; 9 | b = b % a; 10 | if(b == 0) 11 | return a; 12 | } 13 | } 14 | int main() 15 | { 16 | int a,b; 17 | scanf("%d%d",&a,&b); 18 | printf("%d\n",gcd(a,b)); 19 | return 0; 20 | } 21 | 22 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Chapter1/test14.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int n,k,integer_part; 5 | scanf("%d%d",&n,&k); 6 | while(n > k) 7 | { 8 | n -= k; 9 | integer_part++; 10 | } 11 | printf("integer part = %d\nremainder part = %d\n",integer_part,n); 12 | return 0; 13 | } 14 | 15 | 16 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Chapter1/test15.c: -------------------------------------------------------------------------------- 1 | #include 2 | int Factorial(int n) 3 | { 4 | if(n == 0 || n == 1) 5 | return 1; 6 | else 7 | return n * Factorial(n-1); 8 | } 9 | int main() 10 | { 11 | int n; 12 | scanf("%d",&n); 13 | printf("%d! = %d\n",n,Factorial(n)); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Chapter1/test16.c: -------------------------------------------------------------------------------- 1 | #include 2 | int sum_x(int x, int n) 3 | { 4 | int i,sum = 0,k = x; 5 | for(i = 0; i <= n; i++) 6 | { 7 | if(i == 0) 8 | { 9 | sum += 1; 10 | continue; 11 | } 12 | else 13 | { 14 | sum += x; 15 | x *= k; 16 | } 17 | } 18 | return sum; 19 | } 20 | int main() 21 | { 22 | int x,n; 23 | scanf("%d%d",&x,&n); 24 | printf("sum_x = %d\n",sum_x(x,n)); 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Chapter1/test17.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,n,n_square = 1; 5 | scanf("%d",&n); 6 | for(i = 1; i <= n; i++) 7 | { 8 | printf("%d^2 = %d\n",i,n_square); 9 | n_square = n_square + +i+i + 1; 10 | } 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Chapter1/test2.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i = 1,j = 2,k = -7,m = 0,x = 1,y = 1 ,z = 1; 5 | char c = 'x',d; 6 | /* if(x < x + y) 7 | printf("right\n"); 8 | else 9 | printf("wrong\n"); 10 | */ 11 | x = ++x; 12 | printf("%d\n",c); 13 | printf("%d\n",x); 14 | printf("%d\n",y); 15 | printf("%d\n",z); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Chapter1/test3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | double function1(double x) 5 | { 6 | return sqrt(x*x-4.0)/(x-8); 7 | } 8 | int main() 9 | { 10 | double x; 11 | printf("input x = "); 12 | scanf("%lf",&x); 13 | printf("y = %lf\n",function1(x)); 14 | return 0; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Chapter1/test8.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int x,y = 1,z; 5 | while(y < 11) 6 | { 7 | x = y++; 8 | z = ++y; 9 | } 10 | printf("x = %d\ny = %d\nz = %d\n",x,y,z); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Chapter1/test9.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | printf("%d\n",(1,2)); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Function/test2.c: -------------------------------------------------------------------------------- 1 | #include 2 | void PrintPrime(int n){ 3 | int i,j,A[n],P[n]; 4 | for(i = 0; i < n; i++) 5 | A[i] = 1; 6 | for(i = 2; i < n; i++) 7 | for(j = 2*i; j < n; j += i) 8 | A[j] = 0; 9 | int k = 0; 10 | for(i = 2; i < n; i++){ 11 | if(A[i]){ 12 | P[k] = i; 13 | k++; 14 | } 15 | } 16 | for(i = 0; i < k; i++){ 17 | if((P[i]+2) == P[i+1]){ 18 | printf("%d %d\n",P[i],P[i+1]); 19 | } 20 | } 21 | } 22 | int main() 23 | { 24 | int n,i,j; 25 | scanf("%d",&n); 26 | PrintPrime(n); 27 | return 0; 28 | } 29 | 30 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Function_arg/test1.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Sat 19 Oct 2019 09:57:03 AM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main() 10 | { 11 | int x = 1; 12 | if(x > 0){ 13 | int x = 3; 14 | printf("%d\n",x); 15 | } 16 | printf("%d\n",x); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Function_arg/test2.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test2.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Sat 19 Oct 2019 10:03:27 AM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | void print_a(void); 10 | int main() 11 | { 12 | int i; 13 | for(i = 0; i < 5; i++) 14 | print_a(); 15 | return 0; 16 | } 17 | void print_a(){ 18 | static int a = 1; 19 | printf("%d\n",a++); 20 | return; 21 | } 22 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Function_arg/test3.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test3.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Sat 19 Oct 2019 10:22:17 AM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | void Print(int a, int b){ 10 | if(a <= b){ 11 | printf("%d\n",a); 12 | Print(a+1,b); 13 | } 14 | return; 15 | } 16 | int main(){ 17 | Print(0,6); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Lecture/Heapsort: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C_CLASS_NEWTEST/Lecture/Heapsort -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Lecture/Quicksort: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C_CLASS_NEWTEST/Lecture/Quicksort -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Lecture/Time: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C_CLASS_NEWTEST/Lecture/Time -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Lecture/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | printf("hello\n"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Linked_list/deque.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | typedef int elemtype; 5 | typedef struct dNode * link; 6 | typedef struct dNode { 7 | elemtype elem; 8 | link prev; 9 | link next; 10 | } dnode; 11 | 12 | 13 | typedef struct Deque { 14 | link front; 15 | link rear; 16 | } deque; 17 | 18 | int main() 19 | { 20 | printf("Hello world!\n"); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Linked_list/myfile: -------------------------------------------------------------------------------- 1 | sa fji jglkasjga 2 | agsgasgj 3 | glsak 4 | asfbjkas 5 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Linked_list/queue.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C_CLASS_NEWTEST/Linked_list/queue.c -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Pointer/test1.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test1.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 14 Oct 2019 08:14:24 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | void swap(int *px, int *py){ 10 | int temp; 11 | temp = *px; 12 | *px = *py; 13 | *py = temp; 14 | } 15 | int main() 16 | { 17 | int a = 1,b = 2; 18 | printf("a = %d\nb = %d\n",a,b); 19 | swap(&a,&b); 20 | printf("a = %d\nb = %d\n",a,b); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Sort_raw_file/fread.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: fread.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 27 Nov 2019 12:44:21 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main(int argc, char *argv[]) 10 | { 11 | int mas[1]; 12 | FILE *fp = fopen(argv[1],"r"); 13 | if(fp == NULL){ 14 | printf("ERROR!\n"); 15 | return 0; 16 | } 17 | while(fread(mas,sizeof(int),1,fp)) 18 | printf("%d\n",mas[0]); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/String/test1.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test1.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 23 Oct 2019 08:38:11 AM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main() 10 | { 11 | int n; 12 | scanf("%d",&n); 13 | char s[100]; 14 | int i; 15 | for(i = 0; i < n ; i++){ 16 | s[i] = 'A' + i; 17 | } 18 | puts(s); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/String/test2.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test2.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 23 Oct 2019 08:43:56 AM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main() 10 | { 11 | char c[100]; 12 | scanf("%s",c); 13 | int sum = 0; 14 | int length = 0; 15 | while(c[length] != '\0'){ 16 | sum += c[length] - '0'; 17 | length++; 18 | } 19 | printf("sum = %d\n",sum); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/String/test3.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test3.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Wed 23 Oct 2019 08:47:18 AM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main() 10 | { 11 | char s1[100]; 12 | scanf("%s",s1); 13 | int i = 0; 14 | while(s1[i] != '\0'){ 15 | if(s1[i] >= 'A' && s1[i] <= 'Z'){ 16 | s1[i] = s1[i] + 32; 17 | } 18 | i++; 19 | } 20 | puts(s1); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/String/test6.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test6.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Fri 25 Oct 2019 10:40:54 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main() 10 | { 11 | char s1[100]; 12 | scanf("%s",s1); 13 | 14 | char s2[100]; 15 | 16 | int i = 0; 17 | while(s1[i] != '\0'){ 18 | s2[i] = s1[i]; 19 | i++; 20 | } 21 | s2[i] = '\0'; 22 | 23 | puts(s2); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Structure/temp.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: temp.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Fri 08 Nov 2019 09:31:18 AM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main() 10 | { 11 | int c[3] = {1,2,3}; 12 | int foo = 1; 13 | c[--foo] = c[foo++]; 14 | printf("foo = %d\n%d %d %d\n",foo,c[0],c[1],c[2]); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/copy: -------------------------------------------------------------------------------- 1 | B 2 |  -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/myfile: -------------------------------------------------------------------------------- 1 | abvk saifh jfaslflksjmsaklhkfas 2 | safjlskaf asfasn jkfnasjknjnka 3 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/myfile1: -------------------------------------------------------------------------------- 1 | hello 2 | sfanjkfksajnf 3 | asvzmsfa 4 | fmska 5 | hello 6 | zxczxcasfasfafgsagas 7 | kmflsa 8 | fsmapo 9 | hellosaffisaojfiasjfsjaifsjl 10 | jjjjjjjjjjjjjjjjj 11 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/myfile2: -------------------------------------------------------------------------------- 1 | world 2 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/temp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C_CLASS_NEWTEST/Task/temp -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/temp.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: temp.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Thu 07 Nov 2019 09:25:47 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | int main() 11 | { 12 | char s[100]; 13 | int i = 0, c; 14 | while((c = getchar()) != '\n') 15 | s[i++] = c; 16 | s[i] = '\0'; 17 | printf("%s\n",s); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/temp1.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: temp1.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 25 Nov 2019 11:21:16 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main() 10 | { 11 | char *s1 = "abcd"; 12 | char *s2 = "efgsaf"; 13 | s2 = s1; 14 | puts(s2); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test1.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test1.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 04 Nov 2019 10:13:37 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | typedef enum SEASON{ 10 | winter = 1, spring, summer, autumn 11 | }season; 12 | int main() 13 | { 14 | enum SEASON season; 15 | season = autumn; 16 | printf("%d\n",season); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test12.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test12.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 11 Nov 2019 07:04:13 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | struct square_point{ 10 | double x; 11 | double y; 12 | }; 13 | struct square_point_color{ 14 | double x; 15 | double y; 16 | char color[50]; 17 | }; 18 | struct complex_number{ 19 | double a; 20 | double b; 21 | }; 22 | struct real_number{ 23 | double a; 24 | } 25 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test16.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test16.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Thu 14 Nov 2019 12:24:16 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | int ques(char *s1, char *s2){ 12 | while(*s1 && *s2 && *s1 ++== *s2++); 13 | return *--s1-*--s2; 14 | } 15 | int main() 16 | { 17 | char s1[100],s2[100]; 18 | scanf("%s%s",s1,s2); 19 | printf("%d\n",ques(s1,s2)); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test18.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test18.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Thu 14 Nov 2019 01:28:25 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int try_to_change_it(int); 10 | int main() 11 | { 12 | int i = 4, j; 13 | j = try_to_change_it(i); 14 | printf("i = %d, j = %d\n",i,j); 15 | return 0; 16 | } 17 | int try_to_change_it(int k) 18 | { 19 | printf("k1 = %d\n",k); 20 | k += 33; 21 | printf("k2 = %d\n",k); 22 | return k; 23 | } 24 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test19.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test19.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Thu 14 Nov 2019 01:32:33 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | void compare(int, int *); 10 | int main() 11 | { 12 | int i = 4, j = 5; 13 | compare(i, &j); 14 | printf("i = %d, j = %d\n",i,j); 15 | return 0; 16 | } 17 | void compare(int k, int *m){ 18 | printf("k1 = %d, *m1 = %d\n",k,*m); 19 | k++; 20 | (*m)++; 21 | printf("k2 = %d, *m2 = %d\n",k,*m); 22 | } 23 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test21.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test21.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Fri 15 Nov 2019 04:41:06 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | #define max1(x,y,z) ((((x)>(y) ? (x):(y)) > ((x)>(z) ? (x):(z))) ? ((x)>(y) ? (x):(y)):((x)>(z) ? (x):(z))) 10 | #define max2(x,y,z) ((x)>(y) ? ((x)>(z) ? (x):(z)) : ((y)>(z) ? (y):(z))) 11 | int main() 12 | { 13 | int a,b,c; 14 | scanf("%d%d%d",&a,&b,&c); 15 | printf("%d\n",max2(a,b,c)); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test29.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test29.cpp 3 | > Author: 4 | > Mail: 5 | > Created Time: Tue 19 Nov 2019 04:08:11 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | using namespace std; 10 | int main(int argc, char *argv[]) 11 | { 12 | int i; 13 | for(i = 1; i < argc; i++) 14 | printf("%s%s",argv[i],(i < argc-1) ? " " : ""); 15 | printf("\n"); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test34.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test34.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Fri 22 Nov 2019 11:30:37 AM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main() 10 | { 11 | int c; 12 | FILE *fp = fopen("myfile","w"); 13 | while((c = getchar()) != '\n') 14 | putc(c,fp); 15 | fclose(fp); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test35.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test35.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Fri 22 Nov 2019 05:08:30 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main(int argc, char *argv[]) 10 | { 11 | for(int i = 1; i < argc; i++){ 12 | FILE *fp = fopen(argv[i],"r"); 13 | char c; 14 | while(fscanf(fp,"%c",&c) != EOF) 15 | printf("%c",c); 16 | fclose(fp); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test36.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test36.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Fri 22 Nov 2019 05:19:22 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main() 10 | { 11 | FILE *fp = fopen("myfile1","r"); 12 | char c; 13 | int count = 0; 14 | while(fscanf(fp,"%c",&c) != EOF) 15 | if(c == '\n') 16 | count++; 17 | fclose(fp); 18 | printf("%d\n",count); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test39.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test39.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Sun 24 Nov 2019 11:23:21 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main(int argc, char *argv[]) 10 | { 11 | FILE *fp = fopen(argv[1],"r"); 12 | FILE *f_cp = fopen("copy","w"); 13 | char c; 14 | while((c = fgetc(fp)) != EOF) 15 | fputc(c,f_cp); 16 | fclose(fp); 17 | fclose(f_cp); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test4.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test4.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Thu 07 Nov 2019 12:55:57 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main(){ 10 | char s[100]; 11 | char *ps = s; 12 | int count = 0; 13 | do{ 14 | scanf("%c",ps); 15 | if(*ps == 'a'){ 16 | count++; 17 | } 18 | ps++; 19 | }while(*(ps-1) != '.'); 20 | *ps = '\0'; 21 | 22 | printf("%d\n",count); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test44.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test44.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Tue 26 Nov 2019 05:02:32 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main(int argc, char *argv[]) 10 | { 11 | int mas[1]; 12 | FILE *fp = fopen(argv[1],"r"); 13 | while(fread(mas,sizeof(mas[0]),1,fp)){ 14 | printf("%d\n",mas[0]); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/Task/test7.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: test7.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Sat 09 Nov 2019 06:55:36 PM CST 6 | ************************************************************************/ 7 | 8 | #include 9 | int main() 10 | { 11 | int n,r = 2,count = 1; 12 | scanf("%d",&n); 13 | while(n >= r){ 14 | r <<= 1; 15 | count++; 16 | } 17 | printf("%d\n",count); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/test/test1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | float a; 6 | printf("input a:"); 7 | scanf("%f",&a); 8 | float t = a; 9 | int n; 10 | printf("input n:"); 11 | scanf("%d",&n); 12 | if( n <= 0 && a == 0) 13 | { 14 | printf("no\n"); 15 | return 0; 16 | } 17 | int i; 18 | if(n > 0) 19 | { for(i = 1; i < n; i++) 20 | a *= t; 21 | printf("%f^%d = %f\n",t,n,a); 22 | } 23 | if(n == 0) 24 | printf("%f^%d = 1\n",t,n); 25 | if(n < 0 && a != 0) 26 | { 27 | for(i = 0; i < -n+1; i++) 28 | a /= t; 29 | printf("%f^%d = %f\n",t,n,a); 30 | } 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/test/test2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #define N 10 5 | int main() 6 | { 7 | int i,flag = 1; 8 | int A[N]; 9 | for(i = 0; i < N; i++) 10 | scanf("%d",&A[i]); 11 | for(i = 0; i < N; i++) 12 | { 13 | if(A[i] >= A[i+1]) 14 | { 15 | printf("no\n"); 16 | flag = 0; 17 | break; 18 | } 19 | } 20 | if(flag == 1) 21 | printf("yes\n"); 22 | 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /C_CLASS_NEWTEST/test/test4.c: -------------------------------------------------------------------------------- 1 | #include 2 | float abs1(float x) 3 | { 4 | if(x < 0) 5 | return -x; 6 | else 7 | return x; 8 | } 9 | float power1(float x, int n) 10 | { 11 | float k = x; 12 | int i; 13 | for(i = 1; i < n; i++) 14 | x *= k; 15 | return x; 16 | } 17 | int main() 18 | { 19 | float eps = 0.00001,x1 = 2.0,x2 = 2.25; 20 | float i = 3; 21 | while(abs1(x1-x2) >= eps) 22 | { 23 | x1 = power1((1+1/i),i); 24 | x2 = power1((1+1/(i+1)),i+1); 25 | i++; 26 | } 27 | printf("x1 = %f\nx2 = %f\n",x1,x2); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /C_CLASS_TEST/input/input_test128.txt: -------------------------------------------------------------------------------- 1 | 1 2 3 4 5 6 7 8 9 10 2 | -------------------------------------------------------------------------------- /C_CLASS_TEST/input/input_test129.txt: -------------------------------------------------------------------------------- 1 | 30 28 33 40 51 91 43 92 25 78 92 41 11 96 54 45 97 66 36 25 53 42 99 2 37 31 44 60 14 36 76 96 17 61 37 20 4 32 12 30 62 57 71 73 5 77 70 2 44 7 28 97 49 79 51 86 10 96 99 77 84 27 73 53 89 62 26 93 94 90 75 8 99 46 81 4 24 52 59 20 11 39 69 12 18 21 50 28 69 49 57 5 77 31 11 18 93 37 11 40 -------------------------------------------------------------------------------- /C_CLASS_TEST/output/output_test128.txt: -------------------------------------------------------------------------------- 1 | Average = 5.500000 2 | -------------------------------------------------------------------------------- /C_CLASS_TEST/output/output_test129.txt: -------------------------------------------------------------------------------- 1 | 30 40 60 20 30 70 10 90 20 50 40 51 91 41 11 31 61 71 51 81 11 21 31 11 11 92 92 42 2 32 12 62 2 62 52 12 33 43 53 73 73 53 93 93 54 44 14 4 44 84 94 4 24 25 45 25 5 75 5 96 66 36 36 76 96 86 96 26 46 97 37 17 37 57 77 7 97 77 27 57 77 37 28 78 28 8 18 28 18 99 49 79 99 89 99 59 39 69 69 49 -------------------------------------------------------------------------------- /C_CLASS_TEST/test1.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,c; 5 | printf("please input three numbers: \n"); 6 | scanf("%d%d%d",&a,&b,&c); 7 | printf("%d + %d + %d = %d\n",a,b,c,a + b + c); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test10.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,c,d,e,max,min; 5 | printf("please input five numbers: \n"); 6 | scanf("%d%d%d%d%d",&a,&b,&c,&d,&e); 7 | 8 | if (a > b) 9 | max = a,min = b; 10 | else 11 | max = b,min = a; 12 | 13 | if (c > max) 14 | max = c; 15 | if (c < min) 16 | min = c; 17 | if (d > max) 18 | max = d; 19 | if (d < min) 20 | min = d; 21 | if (e > max) 22 | max = e; 23 | if (e < min) 24 | min = e; 25 | 26 | printf("max = %d\nmin = %d\nmax + min = %d\n",max,min,max + min); 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test103.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int randomInt(int n) 4 | { 5 | return rand()%n; 6 | } 7 | int main() 8 | { 9 | int a[10],b[10],k = 0,i,j; 10 | srand(time(NULL)); 11 | for(i = 0; i < 10; i++) 12 | a[i] = randomInt(1000); 13 | for(i = 0; i < 10; i++) 14 | printf("a[%d] = %d ",i,a[i]); 15 | printf("\n"); 16 | for(i = 0; i < 10; i++) 17 | { 18 | if (((a[i]/10)%10) == 0) 19 | { 20 | b[k] = a[i]; 21 | k++; 22 | } 23 | } 24 | for(j = 0; j < k; j++) 25 | { 26 | printf("b[%d] = %d ",j,b[j]); 27 | } 28 | printf("\n"); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test107.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int randomInt(int n) 4 | { 5 | return rand()%n + 2; 6 | } 7 | int main() 8 | { 9 | int k,i,j,multiple; 10 | srand(time(NULL)); 11 | k = randomInt(97); 12 | printf("k = %d\n",k); 13 | for(j = 2; j < 10; j++) 14 | { 15 | for(i = k; i > 0 ; i--) 16 | { 17 | if(i % j == 0) 18 | { 19 | multiple = i/j; 20 | break; 21 | } 22 | else 23 | multiple = 0; 24 | } 25 | printf("%d--%d\n",j,multiple); 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test109.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int digit[10] = {}, n,i,j,currentDigit; 5 | 6 | printf("input number: "); 7 | scanf("%d",&n); 8 | while(n) 9 | { 10 | currentDigit = n%10; 11 | digit[currentDigit]++; 12 | n /= 10; 13 | } 14 | for(i = 0; i <= 9 ;i++) 15 | for(j = 0; j < digit[i]; j++) 16 | printf("%d ",i); 17 | printf("\n"); 18 | return 0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test11.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,c,d,e,max,min; 5 | printf("please input five numbers: \n"); 6 | scanf("%d%d%d%d%d",&a,&b,&c,&d,&e); 7 | 8 | max = (a > b) ? a : b; 9 | min = (a < b) ? a : b; 10 | 11 | max = (c > max) ? c : max; 12 | min = (c < min) ? c : min; 13 | 14 | max = (d > max) ? d : max; 15 | min = (d < min) ? d : min; 16 | 17 | max = (e > max) ? e : max; 18 | min = (e < min) ? e : min; 19 | 20 | printf("max = %d\nmin = %d\nmax + min = %d\n",max,min,max + min); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test116.c: -------------------------------------------------------------------------------- 1 | #include 2 | int judge_array(int a[], int n) 3 | { 4 | int i,j; 5 | for (i = 0; i < n; i++) 6 | { 7 | for (j = i+1; j < n; j++) 8 | { 9 | if (a[i] == a[j]) 10 | return 1; 11 | } 12 | } 13 | return 0; 14 | } 15 | int main() 16 | { 17 | int a[5] = {1,2,3,5,4}; 18 | if (judge_array(a,5)) 19 | printf("right\n"); 20 | else 21 | printf("wrong\n"); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test118.c: -------------------------------------------------------------------------------- 1 | #include 2 | int lacked_number(int a[],int n) 3 | { 4 | int sum_n = n * (n + 1)/2,sum_array = 0, i; 5 | for (i = 0; i < n; i++) 6 | sum_array += a[i]; 7 | return sum_n - sum_array; 8 | } 9 | int main() 10 | { 11 | int a[10],n = 9,i = 0,element; 12 | do 13 | { 14 | scanf("%d",&element); 15 | a[i] = element; 16 | i++; 17 | }while(element != 0); 18 | printf("lacked number = %d\n",lacked_number(a,n)); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test119.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char q[80]; 5 | int i; 6 | printf("input string\n"); 7 | scanf("%s",q); 8 | i = 0; 9 | while(q[i] != '\0') 10 | { 11 | if (q[i] == 'a') 12 | q[i] = 'b'; 13 | i++; 14 | } 15 | printf("reslut: %s\n",q); 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test12.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,a1,a2,a3,max; 5 | printf("please input a number: \n"); 6 | scanf("%d",&a); 7 | a1 = a/100; 8 | a2 = (a/10) % 10; 9 | a3 = a%10; 10 | 11 | printf("sum = %d\n",a1 + a2 + a3); 12 | printf("product = %d\n",a1 * a2 * a3); 13 | 14 | if (a1 > a2) 15 | max = a1; 16 | else 17 | max = a2; 18 | if (a3 > max) 19 | max = a3; 20 | 21 | printf("max = %d\n",max); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test126.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define N 8 4 | #define M 8 5 | int main() 6 | { 7 | int a[N][M],i,j,max,max_i = 0; 8 | srand(time(NULL)); 9 | for(i = 0; i < N; i++) 10 | for(j = 0; j < M; j++) 11 | a[i][j] = rand()%10; 12 | 13 | for(i = 0; i < N; i++) 14 | { 15 | for(j = 0; j < M; j++) 16 | printf("%2d ",a[i][j]); 17 | printf("\n"); 18 | } 19 | max = a[0][0]; 20 | for(i = 1; i < N; i++) 21 | { 22 | if(max < a[i][i]) 23 | { 24 | max_i = i; 25 | max = a[i][i]; 26 | } 27 | } 28 | printf("max = %d\nmax_i = %d\n",max,max_i); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test128.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | FILE *f; 5 | int x,n,count = 0,sum = 0; 6 | f = fopen("input/input_test128.txt","r"); 7 | if(f == NULL) 8 | { 9 | printf("can't find file\n"); 10 | return 0; 11 | } 12 | do 13 | { 14 | n = fscanf(f, "%d",&x); 15 | if (n != 1) 16 | break; 17 | sum+=x; 18 | count++; 19 | }while(n == 1); 20 | fclose(f); 21 | f = fopen("output/output_test128.txt","w"); 22 | fprintf(f,"Average = %f\n",(float)sum/count); 23 | fclose(f); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test13.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | float x1,x2,y1,y2,k,b; 5 | printf("Input x1: \n"); 6 | scanf("%f",&x1); 7 | printf("Input y1: \n"); 8 | scanf("%f",&y1); 9 | printf("Input x2: \n"); 10 | scanf("%f",&x2); 11 | printf("Input y2: \n"); 12 | scanf("%f",&y2); 13 | 14 | k = (y2 - y1)/(x2 - x1); 15 | b = (y2 -x2 * (y2 - y1)/(x2 - x1)); 16 | printf("the function is :y = %fx+%f\n",k,b); 17 | 18 | return 0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test132.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char s[52],input_string[80]; 5 | int i,a,N; 6 | for(i = 0; i < 52; i++) 7 | { 8 | s[i] = 'a' + i; 9 | if (i > 25) 10 | s[i] = 'a' + (i - 26); 11 | } 12 | printf("input the string:"); 13 | scanf("%s",&input_string); 14 | printf("input the number:"); 15 | scanf("%d",&N); 16 | for(i = 0; input_string[i] != '\0'; i++) 17 | { 18 | for(a = 0; a < 26; a++) 19 | { 20 | if(input_string[i] == s[a]) 21 | { 22 | printf("%c",s[a+N]); 23 | break; 24 | } 25 | } 26 | } 27 | printf("\n"); 28 | return 0; 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test14.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a, b, c; 5 | printf("please input three numbers: \n"); 6 | scanf("%d%d%d",&a,&b,&c); 7 | 8 | if (a < b && b < c) 9 | printf("yes\n"); 10 | else 11 | printf("not\n"); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test15.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a; 5 | printf("please input the month: \n"); 6 | scanf("%d",&a); 7 | 8 | if (3 <= a && a <= 5) 9 | printf("spring!\n"); 10 | if (6 <= a && a<= 8) 11 | printf("summer!\n"); 12 | if (9 <= a && a<= 11) 13 | printf("autumn!\n"); 14 | if (a == 12 || (1 <= a && a<= 2)) 15 | printf("winter!\n"); 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test16.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a, b; 5 | printf("please input two numbers: \n"); 6 | scanf("%d%d",&a,&b); 7 | 8 | if (a > b) 9 | printf("Above\n"); 10 | if (a < b) 11 | printf("Less\n"); 12 | if (a == b) 13 | printf("Equal\n"); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test17.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a, b, c; 5 | printf("please input 3 numbers: \n"); 6 | scanf("%d%d%d",&a,&b,&c); 7 | 8 | if ((a + b) > c && (a + c) > b && (b + c) > a) 9 | printf("triangle!\n"); 10 | else 11 | printf("No!\n"); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test18.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,i; 5 | printf("input a number: \n"); 6 | scanf("%d",&a); 7 | i = 1; 8 | 9 | while (i <= a) 10 | { 11 | printf("%d: %d %d\n",i ,i*i, i*i*i); 12 | i++; 13 | } 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test19.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,t; 5 | printf("input two number: \n"); 6 | scanf("%d%d",&a,&b); 7 | 8 | if (a > b) 9 | t = a, a = b, b = t; 10 | 11 | while (a <= b) 12 | { 13 | printf("%d: %d %d\n",a ,a*a, a*a*a); 14 | a++; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test2.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,c; 5 | printf("please input three numbers: \n"); 6 | scanf("%d%d%d",&a,&b,&c); 7 | printf("%d + %d + %d = %d\n",a,b,c,a + b + c); 8 | printf("%d * %d * %d = %d\n",a,b,c,a*b*c); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test20.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,t,i,sum; 5 | sum = 0; 6 | printf("input two number: \n"); 7 | scanf("%d%d",&a,&b); 8 | 9 | if (a > b) 10 | t = a, a = b, b = t; 11 | 12 | while (a <= b) 13 | { 14 | i = a * a; 15 | sum = sum + i; 16 | a++; 17 | } 18 | printf("%d\n",sum); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test21.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,i; 5 | printf("please input a number: \n"); 6 | scanf("%d",&a); 7 | i = 0; 8 | 9 | while (a != 0) 10 | { 11 | a = a / 10; 12 | i++ ; 13 | } 14 | 15 | if (i == 3) 16 | printf("Yes!\n"); 17 | else 18 | printf("No!\n") ; 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test22.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,sum,i; 5 | printf("please input a number: \n"); 6 | scanf("%d",&a); 7 | sum = 0; 8 | while (a != 0) 9 | { 10 | i = a % 10 ; 11 | a = a / 10 ; 12 | sum = sum + i; 13 | } 14 | printf("%d\n",sum); 15 | 16 | return 0 ; 17 | } 18 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test23.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,i; 5 | printf("please input a number: \n"); 6 | scanf("%d",&a); 7 | 8 | while (a != 0) 9 | { 10 | if (a % 10 == (a / 10) % 10) 11 | { 12 | printf("Yes\n"); 13 | break ; 14 | } 15 | a = a / 10; 16 | } 17 | 18 | return 0 ; 19 | } 20 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test24.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,i,k = 0; 5 | printf("please input a number: \n"); 6 | scanf("%d",&a); 7 | 8 | while (a != 0) 9 | { 10 | i = a; 11 | while (i != 0) 12 | { 13 | if (a%10 == (i / 10) % 10) 14 | { 15 | printf("Yes\n"); 16 | k ++; 17 | return 0; 18 | } 19 | i = i/10; 20 | } 21 | a = a / 10; 22 | } 23 | if (k == 0) 24 | printf("No!\n"); 25 | return 0 ; 26 | } 27 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test25.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,a,k; 5 | 6 | printf("input a number: \n"); 7 | scanf("%d",&i); 8 | k = 0; 9 | while (i != 0) 10 | { 11 | a = i % 10; 12 | if (a == 9) 13 | { 14 | k++; 15 | } 16 | i = i / 10; 17 | } 18 | if (k == 1) 19 | printf("yes\n"); 20 | else 21 | printf("no\n"); 22 | 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test26.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,a,b,k; 5 | 6 | printf("input a number: \n"); 7 | scanf("%d",&i); 8 | k = 0; 9 | while (i != 0) 10 | { 11 | a = i % 10; 12 | b =( (i/10) % 10 ); 13 | 14 | if (a < b) 15 | { 16 | k = k - 1; 17 | } 18 | i = i / 10; 19 | } 20 | if (k >= 0) 21 | printf("yes\n"); 22 | else 23 | printf("no\n"); 24 | 25 | return 0; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test27.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,a,b,k; 5 | 6 | printf("input a number: \n"); 7 | scanf("%d",&i); 8 | k = 0; 9 | while (i != 0) 10 | { 11 | a = i % 10; 12 | printf("%d",a); 13 | i = i / 10; 14 | } 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test28.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,a,b,k; 5 | 6 | printf("input a number: \n"); 7 | scanf("%d",&i); 8 | k = 0; 9 | while (i != 0) 10 | { 11 | a = i % 10; 12 | 13 | if ((a%2) != 0) 14 | { 15 | k = k - 1; 16 | } 17 | i = i / 10; 18 | } 19 | if (k >= 0) 20 | printf("yes\n"); 21 | else 22 | printf("no\n"); 23 | 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test29.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,a,b,max,min; 5 | 6 | printf("input a number: \n"); 7 | scanf("%d",&i); 8 | max = min = i%10; 9 | while (i != 0) 10 | { 11 | a = i % 10; 12 | 13 | if (a > max) 14 | max = a; 15 | if (a < min) 16 | min = a; 17 | 18 | i = i/10; 19 | } 20 | printf("max = %d\nmin = %d\n",max,min); 21 | 22 | return 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test3.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,c; 5 | printf("please input three numbers: \n"); 6 | scanf("%d%d%d",&a,&b,&c); 7 | printf("%d + %d + %d = %d\n",a,b,c,a + b + c); 8 | printf("%d * %d * %d = %d\n",a,b,c,a*b*c); 9 | double d = (double) (a + b + c)/3; 10 | printf("(%d + %d + %d)/3 = %f\n",a,b,c,d); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test30.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,a,b,odd,even; 5 | 6 | printf("input a number: \n"); 7 | scanf("%d",&i); 8 | odd = 0; 9 | even = 0; 10 | while (i != 0) 11 | { 12 | a = i % 10; 13 | 14 | if (a%2 == 0) 15 | even++ ; 16 | else 17 | odd++ ; 18 | 19 | 20 | i = i/10; 21 | } 22 | printf("even = %d\nodd = %d\n",even,odd); 23 | 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test31.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a, count; 5 | printf("input number \n"); 6 | scanf("%d",&a); 7 | count = 0; 8 | while(a != 0) 9 | { 10 | scanf("%d",&a); 11 | count++; 12 | } 13 | printf("count = %d\n",count); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test32.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a, count; 5 | printf("input number \n"); 6 | scanf("%d",&a); 7 | count = 0; 8 | while(a != 0) 9 | { 10 | if (a%2 == 0) 11 | count++; 12 | scanf("%d",&a); 13 | } 14 | printf("count = %d\n",count); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test33.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a, b,i = 0; 5 | printf("input number: \n"); 6 | scanf("%d%d",&a,&b); 7 | while (a != 0 && b != 0) 8 | { 9 | if (a > b) 10 | a = a % b; 11 | else 12 | b = b % a; 13 | 14 | i++; 15 | } 16 | printf("%d\n%d\n",a + b,i); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test34.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | float a,b,c,d,s; 6 | s = 1; 7 | a = 2; 8 | b = 3; 9 | c = 3; 10 | d = 1; 11 | while (fabs((d*a)/(b*c))> 0.001) 12 | { 13 | s = s + (d*a)/(b*c); 14 | a = a + 2; 15 | d = (-1)*d; 16 | b = b + 2; 17 | c = c * 3; 18 | } 19 | printf("s = %f\n",s); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test35.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | float a,b,c,d,b3,b2,s; 6 | s = (float)4/3; 7 | a = 4; 8 | b = 3; 9 | c = 9; 10 | d = -1; 11 | b3 = 3; 12 | b2 = 2; 13 | while (fabs((d*a)/(b*c))> 0.0001) 14 | { 15 | s = s + (d*a)/(b*c); 16 | a = a + 2; 17 | d = (-1)*d; 18 | c = c * 3; 19 | b = b2 + b3; 20 | b2 = b3; 21 | b3 = b; 22 | 23 | } 24 | printf("s = %f\n",s); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test36.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,c,d,count1,count2; 5 | printf("input two numbers: \n"); 6 | scanf("%d%d",&a,&b); 7 | c = a; 8 | d = b; 9 | count1 = 0; 10 | count2 = 0; 11 | while(a != 0 && b != 0) 12 | { 13 | if (a > b) 14 | a = a - b; 15 | else 16 | b = b - a; 17 | count1 ++; 18 | } 19 | 20 | while (c != 0 && d != 0) 21 | { 22 | if (c > d) 23 | c = c % d; 24 | else 25 | d = d % c; 26 | count2 ++; 27 | } 28 | 29 | printf("%d\ncount1 = %d\n",a + b,count1); 30 | printf("%d\ncount2 = %d\n",c + d,count2); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test37.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,i; 5 | i = 0; 6 | printf("input a number: \n"); 7 | do 8 | { 9 | scanf("%d",&a); 10 | if (a <= 0) 11 | printf("input a positive number: \n"); 12 | } 13 | while(a <= 0); 14 | 15 | while(a != 0) 16 | { 17 | i = a % 10 + i; 18 | a = a/10; 19 | } 20 | 21 | if (i == 10) 22 | printf("yes\n"); 23 | else 24 | printf("no\n"); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test38.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,i,sum; 5 | sum = 0; 6 | i = 0; 7 | printf("input a number: \n"); 8 | do 9 | { 10 | scanf("%d",&a); 11 | if (a <= 0) 12 | printf("input a positive number: \n"); 13 | } 14 | while(a <= 0); 15 | 16 | while(a != 0) 17 | { 18 | sum = a % 10 + sum; 19 | i = (a % 10) * i; 20 | a = a/10; 21 | } 22 | 23 | if (i == sum) 24 | printf("yes\n"); 25 | else 26 | printf("no\n"); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test39.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,i,sum,k; 5 | sum = 0; 6 | i = 1; 7 | printf("input a number >= 10: \n"); 8 | do 9 | { 10 | scanf("%d",&a); 11 | if (a <= 10) 12 | printf("input a number >= 10: \n"); 13 | } 14 | while(a <= 10); 15 | 16 | while( a != 10) 17 | { 18 | k = a; 19 | 20 | while( k != 0) 21 | { 22 | sum = k % 10 + sum; 23 | i = (k % 10) * i; 24 | k = k/10; 25 | 26 | } 27 | 28 | if (i == sum) 29 | printf("%d\n",a); 30 | 31 | sum = 0, i = 1; 32 | 33 | a--; 34 | } 35 | 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test4.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,c; 5 | float d; 6 | printf("please input three numbers: \n"); 7 | scanf("%d%d%d",&a,&b,&c); 8 | printf("%d + %d + %d = %d\n",a,b,c,a + b + c); 9 | printf("%d * %d * %d = %d\n",a,b,c,a*b*c); 10 | d = (a + b + c)/3; 11 | printf("(%d + %d + %d)/3 = %f\n",a,b,c,d); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test40.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char a; 5 | int i = 0; 6 | printf("please input char: "); 7 | 8 | do 9 | { 10 | scanf("%c",&a); 11 | i++ ; 12 | } 13 | while( a != '.'); 14 | 15 | printf("%d\n",i); 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test41.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char a; 5 | int sum = 0; 6 | printf("please input char: "); 7 | 8 | do 9 | { 10 | scanf("%c",&a); 11 | if (a >= '0' && a <= '9') 12 | { 13 | a = a - '0'; 14 | sum = sum + a; 15 | } 16 | } 17 | while( a != '.'); 18 | 19 | printf("%d\n",sum); 20 | 21 | } 22 | 23 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test43.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,i,sum; 5 | sum = 0; 6 | i = 0; 7 | printf("input a number: \n"); 8 | do 9 | { 10 | scanf("%d",&a); 11 | if (a <= 0) 12 | printf("input a positive number: \n"); 13 | } 14 | while(a <= 0); 15 | 16 | while(a != 0) 17 | { 18 | a = i; 19 | while () 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test44.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,k; 5 | printf("input number: "); 6 | scanf("%d",&a); 7 | printf("input power: "); 8 | scanf("%d",&b); 9 | k = a; 10 | while (b != 1) 11 | { 12 | a = a * k; 13 | b--; 14 | } 15 | printf("Answer:%d\n",a); 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test45.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,c,d,max,min; 5 | printf("input number: "); 6 | scanf("%d",&a); 7 | max = a%10; 8 | min = a%10; 9 | while(a != 0) 10 | { 11 | if (a%10 > max) 12 | max = a%10; 13 | if (a%10 < min) 14 | min = a%10; 15 | a = a/10; 16 | } 17 | printf("answer: %d\n",max+min); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test46.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int n,k,i; 5 | scanf("%d",&n); 6 | k = 1; 7 | i = 0; 8 | 9 | while(k != (n+1)) 10 | { 11 | while( i != k ) 12 | { 13 | printf("*"); 14 | i++; 15 | } 16 | printf("\n"); 17 | k++; 18 | i = 0; 19 | 20 | } 21 | return 0; 22 | } 23 | 24 | 25 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test47.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,c,n,i; 5 | i = 1; 6 | b = 0; 7 | printf("input number: "); 8 | scanf("%d",&n); 9 | 10 | while(n != 0) 11 | { 12 | a = n%3; 13 | n = n/3; 14 | b = b + a*i; 15 | i = i*10; 16 | } 17 | printf("Answer: %d\n",b); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test48.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n,i; 6 | printf("input number: "); 7 | scanf("%d",&n); 8 | for (i = n; i >= 1; i-=2) 9 | { 10 | printf("%d ",i); 11 | } 12 | printf("\n"); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test49.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n1,n2,i; 6 | printf("input number: "); 7 | scanf("%d%d",&n1,&n2); 8 | for (i = n1; i <= n2; i++ ) 9 | { 10 | printf("%d*%d*%d = %d\n",i,i,i,i*i*i); 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test5.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a; 5 | printf("please input a number: \n"); 6 | scanf("%d",&a); 7 | a = a / 10; 8 | a = a % 10; 9 | printf("answer = %d",a); 10 | return 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test50.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | float i,n,sum = 0; 6 | printf("input number: "); 7 | scanf("%f",&n); 8 | for (i = 1; i <= n; i += 0.1) 9 | { 10 | sum += i*i; 11 | } 12 | printf("sum = %f\n",sum); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test51.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n,i,a0 = 0,a1 = 1,c; 6 | printf("input number: "); 7 | scanf("%d",&n); 8 | for (i = 1; i <= n; i++) 9 | { 10 | printf("%d ",a1); 11 | c = a1; 12 | a1 = a0 + a1; 13 | a0 = c; 14 | } 15 | printf("\n"); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test52.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,i,sum = 0; 5 | printf("input number: "); 6 | scanf("%d%d",&a,&b); 7 | 8 | for(i = a; i <= b; i++) 9 | { 10 | sum += i*i; 11 | } 12 | printf("sum = %d\n",sum); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test53.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,n; 5 | printf("input number: "); 6 | scanf("%d",&n); 7 | 8 | for(i = 1; i <= n; i++) 9 | { 10 | printf("%d: %d %d\n",i,i*i,i*i*i); 11 | } 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test54.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,i; 5 | printf("input number: "); 6 | scanf("%d%d",&a,&b); 7 | 8 | for(i = a; i <= b; i++) 9 | { 10 | printf("%d * %d = %d\n",i,i,i*i); 11 | } 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test55.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,n,a = 1; 5 | printf("input number: "); 6 | scanf("%d",&n); 7 | for(i = 1; i <= n; i++) 8 | { 9 | a = a * i ; 10 | } 11 | printf("%d\n",a); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test56.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int i,n,a = 0; 5 | printf("input number: "); 6 | scanf("%d",&n); 7 | if (n == 2) 8 | { 9 | printf("prime\n"); 10 | return 0; 11 | } 12 | 13 | if (n == 1) 14 | { 15 | printf("not prime and not not prime"); 16 | return 0; 17 | } 18 | 19 | for(i = 2; i <= (n - 1)/2; i++) 20 | { 21 | if (n % i == 0) 22 | { 23 | printf("not prime\n"); 24 | a = 1; 25 | return 0; 26 | } 27 | 28 | } 29 | if (a == 0) 30 | printf("prime\n"); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test58.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int M,day,total_days = 0,i,current_day; 5 | printf("input month: "); 6 | scanf("%d",&M); 7 | printf("input day: "); 8 | scanf("%d",¤t_day); 9 | 10 | for(i = 1; i < M; i++) 11 | { 12 | switch(M) 13 | { 14 | case 2: day = 28;break; 15 | case 4: case 6: case 9: case 11:day = 30;break; 16 | 17 | case 1: case 3: case 5: case 7: case 8: 18 | case 10: case 12: day = 31;break; 19 | 20 | default : day = -1; 21 | } 22 | total_days += day; 23 | } 24 | 25 | printf("you still have %d days.\n",365-(total_days + current_day)); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test59.c: -------------------------------------------------------------------------------- 1 | #include 2 | int model (int x) 3 | { 4 | if (x <= 0) 5 | x = -x; 6 | 7 | return x; 8 | } 9 | int maxmium (int x,int y) 10 | { 11 | if (x > y) 12 | return x; 13 | else 14 | return y; 15 | } 16 | int power (int x,int y) 17 | { 18 | int i,m = 1; 19 | for (i = 1; i <= y;i++) 20 | { 21 | m = m * x; 22 | } 23 | return m; 24 | } 25 | int main() 26 | { 27 | int n,n1; 28 | printf("input two number: "); 29 | scanf("%d%d",&n,&n1); 30 | n = power(n,n1); 31 | printf("%d\n",n); 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test6.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b; 5 | printf("please input two numbers: \n"); 6 | scanf("%d%d",&a,&b); 7 | if (a > b) 8 | { 9 | printf("%d > %d",a,b); 10 | } 11 | else 12 | { 13 | printf("%d < %d",a,b); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test60.c: -------------------------------------------------------------------------------- 1 | #include 2 | float average(float x , float y) 3 | { 4 | return (x + y)/2; 5 | } 6 | int main() 7 | { 8 | float a,b; 9 | scanf("%f%f",&a,&b); 10 | printf("%f\n",average(a,b)); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test61.c: -------------------------------------------------------------------------------- 1 | #include 2 | int function(int x) 3 | { 4 | int f; 5 | if (x >= -2 && x <= 2) 6 | f = x*x; 7 | if (x >= 2) 8 | f = x*x+4*x+5; 9 | if (x < 2) 10 | f = 4; 11 | 12 | return f; 13 | } 14 | int main() 15 | { 16 | int x,max,i = 0; 17 | printf("input number: "); 18 | do 19 | { 20 | scanf("%d",&x); 21 | if (i == 0) 22 | max = function(x); 23 | else if (function(x) > max) 24 | max = function(x); 25 | 26 | i++; 27 | }while(x != 0); 28 | 29 | printf("max = %d\n",max); 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test62.c: -------------------------------------------------------------------------------- 1 | #include 2 | int pow2(int x ) 3 | { 4 | int sum = 0,i,a,m = 1; 5 | for (i = 1 ; i <= x ; i++) 6 | { 7 | m = m*2; 8 | sum = sum + m; 9 | } 10 | sum = sum + 1; 11 | 12 | return sum; 13 | } 14 | int pow1(int x) 15 | { 16 | int i,m = 1; 17 | for (i = 1; i <= (x-1); i++ ) 18 | { 19 | m = m*2; 20 | } 21 | return m; 22 | } 23 | int sum(int x) 24 | { 25 | int i,sum = 0; 26 | for (i = 1; i <= x ; i++) 27 | { 28 | sum = sum + i; 29 | } 30 | return sum; 31 | } 32 | int main() 33 | { 34 | int x; 35 | printf("input number: "); 36 | scanf("%d",&x); 37 | printf("m = %d\n",pow1(x)); 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test63.c: -------------------------------------------------------------------------------- 1 | #include 2 | int function(int x ,int y) 3 | { 4 | int i = 1,a,b = 0; 5 | while (x != 0) 6 | { 7 | a = x%y; 8 | x = x/y; 9 | b = b + a*i; 10 | i = i*10; 11 | } 12 | return b; 13 | } 14 | int main() 15 | { 16 | int x,y; 17 | printf("input x and y : "); 18 | scanf("%d%d",&x,&y); 19 | printf("%d\n",function(x,y)); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test64.c: -------------------------------------------------------------------------------- 1 | #include 2 | char upChar(char ch) 3 | { 4 | char newch = ch; 5 | if(ch >= 'a' && ch <= 'z') 6 | newch = 'A' + (ch - 'a'); 7 | return newch; 8 | } 9 | int main() 10 | { 11 | char ch; 12 | printf("input a string: "); 13 | do 14 | { 15 | scanf("%c",&ch); 16 | printf("%c",upChar(ch)); 17 | }while( ch != '.'); 18 | 19 | printf("\n"); 20 | return 0; 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test65.c: -------------------------------------------------------------------------------- 1 | #include 2 | int class_ride(int x) 3 | { 4 | int i,s = 1; 5 | for(i = 1; i <= x ; i++ ) 6 | { 7 | s = s * i; 8 | } 9 | return s; 10 | 11 | } 12 | int main() 13 | { 14 | int x; 15 | printf("input number: "); 16 | scanf("%d",&x); 17 | printf("class ride = %d\n",class_ride(x)); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test66.c: -------------------------------------------------------------------------------- 1 | #include 2 | int factor() 3 | { 4 | int x,i,a = 0; 5 | printf("input a number: "); 6 | scanf("%d",&x); 7 | printf("%d =",x); 8 | while(x != 0) 9 | { 10 | for (i = 2; i <= x; i++) 11 | { 12 | if ( x % i == 0 && a == 0 ) 13 | { 14 | printf(" %d",i); 15 | a++; 16 | break; 17 | } 18 | if (x % i == 0 && a != 0 ) 19 | { 20 | printf(" * %d",i); 21 | break; 22 | } 23 | } 24 | x = x / i; 25 | } 26 | printf("\n"); 27 | return 0; 28 | } 29 | int main() 30 | { 31 | int x; 32 | factor(x); 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test67.c: -------------------------------------------------------------------------------- 1 | #include 2 | int factor(int x) 3 | { 4 | int i; 5 | for (i = 2; i <= x; i++) 6 | { 7 | if(x % i == 0) 8 | return i; 9 | } 10 | return 0; 11 | } 12 | int main() 13 | { 14 | int x,i,a = 0; 15 | printf("input a number: "); 16 | scanf("%d",&x); 17 | printf("%d =",x); 18 | 19 | while (x != 1) 20 | { 21 | if (a == 0) 22 | { 23 | printf(" %d", factor(x)); 24 | a++; 25 | } 26 | else 27 | printf(" * %d",factor(x)); 28 | 29 | i = factor(x); 30 | x = x/i; 31 | } 32 | printf("\n"); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test68.c: -------------------------------------------------------------------------------- 1 | #include 2 | int factor(int a, int b) 3 | { 4 | while( a != 0 && b != 0) 5 | { 6 | if (a > b) 7 | a = a % b; 8 | else 9 | b = b % a; 10 | } 11 | return (a + b); 12 | } 13 | int main() 14 | { 15 | int a ,b; 16 | printf("input two numbers: "); 17 | scanf("%d%d",&a,&b); 18 | printf("factor = %d\n",factor(a,b)); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test7.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b,c; 5 | printf("please input three numbers: \n"); 6 | scanf("%d%d%d",&a,&b,&c); 7 | 8 | if (a > b && a > c) 9 | printf("max = %d\n",a); 10 | if (b > a && b > c) 11 | printf("max = %d\n",b); 12 | if (c > a && c > b) 13 | printf("max = %d\n",c); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test71.c: -------------------------------------------------------------------------------- 1 | #include 2 | int order(int x) 3 | { 4 | int i1,i2,a = 0; 5 | while (x != 0) 6 | { 7 | i1 = x % 10; 8 | i2 = (x / 10) % 10; 9 | if (i1 < i2) 10 | { 11 | a ++; 12 | return (a == 0); 13 | } 14 | x /= 10; 15 | } 16 | return ( a == 0); 17 | } 18 | int main() 19 | { 20 | int x; 21 | printf("input a number: "); 22 | scanf("%d",&x); 23 | 24 | if (order(x)) 25 | printf("%d is order",x); 26 | else 27 | printf("%d is not order",x); 28 | 29 | printf("\n"); 30 | return 0; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test72.c: -------------------------------------------------------------------------------- 1 | #include 2 | int isDight(char c) 3 | { 4 | if (c >= '0' && c <= '9') 5 | { 6 | c = c - '0'; 7 | return c ; 8 | } 9 | return 0; 10 | } 11 | int main() 12 | { 13 | char c,sum = 0; 14 | printf("input text: "); 15 | do 16 | { 17 | scanf("%c",&c); 18 | sum += isDight(c); 19 | }while( c != '.'); 20 | 21 | printf("sum = %d\n",sum); 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test73.c: -------------------------------------------------------------------------------- 1 | #include 2 | int judge1(char c) 3 | { 4 | int count1 = 0; 5 | if ( c == '(') 6 | count1++; 7 | 8 | return count1; 9 | } 10 | int judge2(char c) 11 | { 12 | int count2 = 0; 13 | if ( c == ')') 14 | count2++; 15 | 16 | return count2; 17 | } 18 | int main() 19 | { 20 | char c,sum1 = 0,sum2 = 0; 21 | printf("input text: "); 22 | do 23 | { 24 | scanf("%c",&c); 25 | sum1 += judge1(c); 26 | sum2 += judge2(c); 27 | }while(c != '.'); 28 | 29 | if (sum1 == sum2) 30 | printf("yes\n"); 31 | else 32 | printf("no\n"); 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test74.c: -------------------------------------------------------------------------------- 1 | #include 2 | int judge() 3 | { 4 | char c; 5 | int count = 0; 6 | do 7 | { 8 | scanf("%c",&c); 9 | if (c == '(') 10 | count ++; 11 | if (c == ')') 12 | count --; 13 | if (count < 0) 14 | return 0; 15 | }while( c != '.'); 16 | 17 | if ( count == 0) 18 | return 1; 19 | else 20 | return 0; 21 | } 22 | int main() 23 | { 24 | char c; 25 | printf("input text: "); 26 | if (judge(c)) 27 | printf("yes\n"); 28 | else 29 | printf("no\n"); 30 | return 0; 31 | } 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test75.c: -------------------------------------------------------------------------------- 1 | #include 2 | int classride(int n) 3 | { 4 | if (n == 1) 5 | return 1; 6 | 7 | return classride(n - 1) * n; 8 | } 9 | int main() 10 | { 11 | int n; 12 | scanf("%d",&n); 13 | printf("%d! = %d\n",n,classride(n)); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test76.c: -------------------------------------------------------------------------------- 1 | #include 2 | void printN(int i,int n) 3 | { 4 | if (i == n) 5 | { 6 | printf("%d ",i); 7 | return; 8 | } 9 | if (i > n) 10 | { 11 | printf("%d ",i); 12 | printN(i-1 , n); 13 | } 14 | else 15 | { 16 | printf("%d ",i); 17 | printN(i+1 , n); 18 | } 19 | } 20 | int main() 21 | { 22 | int i,n; 23 | scanf("%d%d",&i,&n); 24 | printN(i,n); 25 | printf("\n"); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test78.c: -------------------------------------------------------------------------------- 1 | #include 2 | void string(char c) 3 | { 4 | scanf("%c",&c); 5 | if (c == '.') 6 | return; 7 | string(c); 8 | printf("%c",c); 9 | } 10 | int main() 11 | { 12 | char c; 13 | string(c); 14 | printf("\n"); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test79.c: -------------------------------------------------------------------------------- 1 | #include 2 | int two_n(int n) 3 | { 4 | if (n == 0) 5 | return 0; 6 | if (n%2 == 0) 7 | return two_n(n/2); 8 | if (n%2 == 1) 9 | return two_n(n/2) + 1; 10 | } 11 | void print_two_n(int n) 12 | { 13 | if (n == 0) 14 | return; 15 | print_two_n(n/2); 16 | printf("%d",n%2); 17 | } 18 | int main() 19 | { 20 | int n; 21 | printf("input a number: "); 22 | scanf("%d",&n); 23 | print_two_n(n); 24 | printf("\n%d\n",two_n(n)); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test8.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a[4]; 5 | int i = 0, min = 0, max = 0; 6 | printf("please write four numbers: \n"); 7 | for (i = 0; i < 5; i++) 8 | { 9 | scanf("%d",&a[i]); 10 | } 11 | min = a[0]; 12 | for (i = 1; i < 5; i++) 13 | { 14 | if (min > a[i]) 15 | { 16 | min = a[i]; 17 | } 18 | } 19 | printf("min = %d\n",min); 20 | max = a[0]; 21 | for (i = 1; i < 5; i++) 22 | { 23 | if (max < a[i]) 24 | { 25 | max = a[i]; 26 | } 27 | } 28 | 29 | printf("max = %d\n",max); 30 | printf("max + min = %d + %d = %d\n",max,min,max + min); 31 | 32 | return 0; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test80.c: -------------------------------------------------------------------------------- 1 | #include 2 | int number(int n,int a) 3 | { 4 | int i; 5 | for (i = 1; i <= a; i++) 6 | { 7 | printf("%d ",a); 8 | n--; 9 | if (n == 0) 10 | return 0; 11 | } 12 | number(n,a+1); 13 | } 14 | int main() 15 | { 16 | int n; 17 | printf("input a number: "); 18 | scanf("%d",&n); 19 | number(n,1); 20 | printf("\n"); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test81.c: -------------------------------------------------------------------------------- 1 | #include 2 | int factor(int n,int a) 3 | { 4 | if (n == 1) 5 | return 0; 6 | if (n%a == 0) 7 | { 8 | printf("%d ",a); 9 | factor(n/a,a); 10 | } 11 | else 12 | factor(n,a+1); 13 | } 14 | int main() 15 | { 16 | int n; 17 | scanf("%d",&n); 18 | factor(n,2); 19 | printf("\n"); 20 | return 0; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test82.c: -------------------------------------------------------------------------------- 1 | #include 2 | int primer(int n) 3 | { 4 | scanf("%d",&n); 5 | if (n == 0) 6 | return 0; 7 | 8 | primer(n); 9 | 10 | if (n % 2 != 0) 11 | printf("%d ",n); 12 | } 13 | int main() 14 | { 15 | int n; 16 | primer(n); 17 | printf("\n"); 18 | return 0; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test83.c: -------------------------------------------------------------------------------- 1 | #include 2 | int max(int n) 3 | { 4 | int max1; 5 | scanf("%d",&n); 6 | if (n == 0) 7 | return 0; 8 | else 9 | { 10 | max1 = max(n); 11 | if (n > max1) 12 | return n; 13 | else 14 | return max1; 15 | } 16 | } 17 | int main() 18 | { 19 | int n; 20 | printf("%d\n",max(n)); 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test84.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a[5],i; 5 | float sum = 0; 6 | printf("please input five numbers: "); 7 | for(i = 0; i < 5; i++) 8 | { 9 | scanf("%d",&a[i]); 10 | sum += a[i]; 11 | } 12 | printf("average = %f\n",sum/5); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test85.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a[5], i,min,min_index; 5 | printf("please input five numbers: "); 6 | for(i = 0; i < 5; i++) 7 | { 8 | scanf("%d",&a[i]); 9 | if (i == 0) 10 | { 11 | min = a[0]; 12 | min_index = 0; 13 | } 14 | if (a[i] < min) 15 | { 16 | min = a[i]; 17 | min_index = i; 18 | } 19 | } 20 | printf("min = %d\nmin_index = %d\n",min,min_index); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test86.c: -------------------------------------------------------------------------------- 1 | #include 2 | int max(int n1, int n2, int n3) 3 | { 4 | int max1 = n1; 5 | if (n2 > max1) 6 | max1 = n2; 7 | if (n3 > max1) 8 | max1 = n3; 9 | 10 | return max1; 11 | } 12 | int main() 13 | { 14 | int n1,n2,n3; 15 | printf("input 3 numbers: "); 16 | scanf("%d%d%d",&n1,&n2,&n3); 17 | printf("Answer = %d\n",max(n1,n2,n3)); 18 | return 0; 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test87.c: -------------------------------------------------------------------------------- 1 | #include 2 | int number_three(int n) 3 | { 4 | if (n == 0) 5 | return 0; 6 | if (n%10 == 3) 7 | return number_three(n/10) + 1; 8 | if (n%10 != 3) 9 | return number_three(n/10); 10 | } 11 | int main() 12 | { 13 | int n; 14 | printf("input number: "); 15 | scanf("%d",&n); 16 | printf("Answer:%d\n",number_three(n)); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test89.c: -------------------------------------------------------------------------------- 1 | #include 2 | void print_three_n(int n) 3 | { 4 | if (n == 0) 5 | return; 6 | print_three_n(n/3); 7 | printf("%d",n%3); 8 | } 9 | int main() 10 | { 11 | int n; 12 | printf("input number: "); 13 | scanf("%d",&n); 14 | print_three_n(n); 15 | printf("\n"); 16 | return 0; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test90.c: -------------------------------------------------------------------------------- 1 | #include 2 | void printSquare(int n) 3 | { 4 | int i,a = 0; 5 | while (n >= a) 6 | { 7 | for (i = 1;i <= (n-a)/2; i++) 8 | printf(" "); 9 | for (i = 1;i <= a+1; i++) 10 | printf("*"); 11 | 12 | a = a + 2; 13 | printf("\n"); 14 | } 15 | a = a - 2; 16 | while (a >= 1) 17 | { 18 | for (i = 1;i <= (n-a)/2+1; i++) 19 | printf(" "); 20 | for (i = 1;i <= a-1; i++) 21 | printf("*"); 22 | 23 | a = a - 2; 24 | printf("\n"); 25 | } 26 | } 27 | int main() 28 | { 29 | int n; 30 | printf("input number: "); 31 | scanf("%d",&n); 32 | printSquare(n); 33 | return 0; 34 | } 35 | 36 | 37 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test93.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int randomInt(int n) 4 | { 5 | return rand()%n - 10; 6 | } 7 | 8 | int main() 9 | { 10 | int a[10], i,k; 11 | srand(time(NULL)); 12 | for(i = 0; i < 10; i++) 13 | a[i] = randomInt(21); 14 | for(i = 0; i < 10; i++) 15 | printf("a[%d] = %d ",i,a[i]); 16 | printf("\n"); 17 | for (i = 0; i < 5; i++) 18 | { 19 | k = a[i]; 20 | a[i] = a[9-i]; 21 | a[9-i] = k; 22 | } 23 | for(i = 0; i < 10; i++) 24 | printf("a[%d] = %d ",i,a[i]); 25 | printf("\n"); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test94.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int randomInt(int n) 4 | { 5 | return rand()%n - 100; 6 | } 7 | 8 | int main() 9 | { 10 | int a[10], i, sum = 0; 11 | srand(time(NULL)); 12 | for(i = 0; i < 10; i++) 13 | a[i] = randomInt(201); 14 | for(i = 0; i < 10; i++) 15 | printf("a[%d] = %d ",i,a[i]); 16 | printf("\n"); 17 | for (i = 0; i < 10; i++) 18 | { 19 | if (a[i] > 0) 20 | sum += a[i]; 21 | } 22 | printf("sum = %d\n",sum); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test95.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int randomInt(int n) 4 | { 5 | return rand()%n - 12; 6 | } 7 | 8 | int main() 9 | { 10 | int a[12], i, sum = 0; 11 | float avg; 12 | srand(time(NULL)); 13 | for(i = 0; i < 12; i++) 14 | a[i] = randomInt(25); 15 | for(i = 0; i < 12; i++) 16 | printf("a[%d] = %d ",i,a[i]); 17 | printf("\n"); 18 | for (i = 0; i < 12; i++) 19 | { 20 | sum += a[i]; 21 | } 22 | printf("avg = %f\n",sum/12.0); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test98.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int randomInt(int n) 4 | { 5 | return rand()%n - 12; 6 | } 7 | 8 | int main() 9 | { 10 | int a[12], i,k; 11 | srand(time(NULL)); 12 | for(i = 0; i < 12; i++) 13 | a[i] = randomInt(25); 14 | for(i = 0; i < 12; i++) 15 | printf("a[%d] = %d ",i,a[i]); 16 | printf("\n"); 17 | k = a[11]; 18 | for(i = 11; i > 0; i--) 19 | a[i] = a[i-1]; 20 | a[0] = k; 21 | for(i = 0; i < 12; i++) 22 | { 23 | printf("a[%d] = %d ",i,a[i]); 24 | } 25 | printf("\n"); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /C_CLASS_TEST/test99.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int randomInt(int n) 4 | { 5 | return rand()%n - 12; 6 | } 7 | 8 | int main() 9 | { 10 | int a[12], i,b[4]; 11 | srand(time(NULL)); 12 | for(i = 0; i < 12; i++) 13 | a[i] = randomInt(25); 14 | for(i = 0; i < 12; i++) 15 | printf("a[%d] = %d ",i,a[i]); 16 | printf("\n"); 17 | for(i = 0; i < 4; i++) 18 | b[i] = a[i+8]; 19 | for(i = 11; i > 3; i --) 20 | a[i] = a[i-4]; 21 | for(i = 0; i < 4; i++) 22 | a[i] = b[i]; 23 | for(i = 0; i < 12; i++) 24 | { 25 | printf("a[%d] = %d ",i,a[i]); 26 | } 27 | printf("\n"); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_CHOWN/Hello.c: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:Hello.c 3 | * Author: KCN_yu 4 | * Createtime:Mon 12 Oct 2020 06:45:24 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | printf("helloxx\n"); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_CHOWN/Mylink.c: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:Mylink.c 3 | * Author: KCN_yu 4 | * Createtime:Tue 13 Oct 2020 01:37:53 AM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char* argv[]) 13 | { 14 | if(link(argv[1], argv[2]) == -1){ 15 | perror("link"); 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /C_UNIX/Chapter_EXAM/t.c: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:t.c 3 | * Author: KCN_yu 4 | * Createtime:Mon 31 May 2021 07:09:01 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | #include 10 | void SigHandlr(int s){ 11 | printf("world!\n"); 12 | } 13 | int main(int argc, char *argv[]) 14 | { 15 | execlp("grep","grep","-r","-n","exec",NULL); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_EXAM/temp.c: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:temp.c 3 | * Author: KCN_yu 4 | * Createtime:Tue 17 Nov 2020 03:05:30 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | while(1){ 16 | sleep(1); 17 | printf("hello!\n"); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_EXAM/temp2.c: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:temp.c 3 | * Author: KCN_yu 4 | * Createtime:Tue 17 Nov 2020 03:05:30 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | signal(SIGTERM,SIG_IGN); 17 | while(1){ 18 | sleep(1); 19 | printf("world!\n"); 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_EXECL/1.c: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:1.c 3 | * Author: KCN_yu 4 | * Createtime:Tue 20 Oct 2020 01:14:35 AM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | printf("cos(M_PI) = %lf\n",cos(M_PI)); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_EXECL/2.c: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:2.c 3 | * Author: KCN_yu 4 | * Createtime:Tue 20 Oct 2020 01:29:22 AM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | printf("hello world\n"); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/10.txt: -------------------------------------------------------------------------------- 1 | abcdefasf 2 | abcdefasf 3 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/13.txt: -------------------------------------------------------------------------------- 1 | ab12cd34ef56gh78ij9 2 | klmn 3 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/13_f1.txt: -------------------------------------------------------------------------------- 1 | abcdefghijklmn 2 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/13_f2.txt: -------------------------------------------------------------------------------- 1 | 123456789 2 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/14.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C_UNIX/Chapter_FILE/14.txt -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/15_input.txt: -------------------------------------------------------------------------------- 1 |    -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/15_output.c: -------------------------------------------------------------------------------- 1 |   -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/16_input.txt: -------------------------------------------------------------------------------- 1 |    -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/16_output.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C_UNIX/Chapter_FILE/16_output.txt -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/17_input1.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C_UNIX/Chapter_FILE/17_input1.txt -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/17_input2.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C_UNIX/Chapter_FILE/17_input2.txt -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/17_output.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/C_UNIX/Chapter_FILE/17_output.txt -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/6.txt: -------------------------------------------------------------------------------- 1 | abcdabcdefghefgh 2 | 1234kljdd1234 3 | 1234123412341234ab12cd34ef56gh78ij9 4 | klmn 5 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/7.txt: -------------------------------------------------------------------------------- 1 | abcdabcdef 2 | ef 3 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/8.txt: -------------------------------------------------------------------------------- 1 | abcdefghijkl 2 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/9.txt: -------------------------------------------------------------------------------- 1 | 1234kljdd1234 2 | 1234123412341234 -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/9f.txt: -------------------------------------------------------------------------------- 1 | 1234 2 | 5678 3 | 5678 4 | 5678 5 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/9g.txt: -------------------------------------------------------------------------------- 1 | 5678 2 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/Copy_4.c: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:Copy_4.c 3 | * Author: KCN_yu 4 | * Createtime:Tue 22 Sep 2020 10:57:17 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | char buf; 16 | int n; 17 | while((n = read(0,&buf,1)) > 0) write(1,&buf,n); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/fread.c: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:fread.c 3 | * Author: KCN_yu 4 | * Createtime:Tue 29 Sep 2020 12:17:33 AM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | int f = open(argv[1],O_RDONLY); 16 | int buf; 17 | int n; 18 | while((n = read(f,&buf,sizeof(int))) > 0) printf("%d\n",buf); 19 | close(f); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_FILE/temp.txt: -------------------------------------------------------------------------------- 1 |     -------------------------------------------------------------------------------- /C_UNIX/Chapter_KONC/test2.c: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:test2.c 3 | * Author: KCN_yu 4 | * Createtime:Tue 17 Nov 2020 09:58:33 AM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | 10 | int main(int argc, char *argv[]) 11 | { 12 | printf("abc"); 13 | fflush(stdout); 14 | fork(); 15 | printf("bcd\n"); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_MSG/messages.h: -------------------------------------------------------------------------------- 1 | #ifndef __MESSAGES_H__ 2 | #define __MESSAGES_H__ 3 | 4 | #define MESSAGE_SIZE 1024 5 | #define DEFAULT_MESSAGE_TYPE 1 6 | #define CONFIRM_MESSAGE_TYPE 2 7 | 8 | struct msgbuf 9 | { 10 | long mtype; 11 | char mtext[MESSAGE_SIZE]; 12 | }; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_PIPE/1.txt: -------------------------------------------------------------------------------- 1 | abcdefghijklmn 2 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_PIPE/2.txt: -------------------------------------------------------------------------------- 1 | 123456789 2 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_PIPE/3.txt: -------------------------------------------------------------------------------- 1 | opqrst 2 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_PIPE/5.txt: -------------------------------------------------------------------------------- 1 | abcdefg 2 | hijk 3 | lksfak 4 | hfaiushfiuah 5 | klja 6 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_PIPE/res.txt: -------------------------------------------------------------------------------- 1 | g 2 | hijk 3 | 4 | 5 | klja 6 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_PROCESS/1.txt: -------------------------------------------------------------------------------- 1 | abababababa 2 | -------------------------------------------------------------------------------- /C_UNIX/Chapter_STAT/fread_complex.c: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:fread_complex.c 3 | * Author: KCN_yu 4 | * Createtime:Mon 05 Oct 2020 03:33:11 PM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | int f = open(argv[1],O_RDONLY); 16 | double buf[2]; 17 | int n; 18 | while((n = read(f,buf,sizeof(double)*2)) > 0) printf("%f+%lfI\n",buf[0],buf[1]); 19 | close(f); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /C_UNIX/Temp/1.txt: -------------------------------------------------------------------------------- 1 | total 28 2 | -rw------- 1 root root 0 Oct 23 17:34 1.txt 3 | -rwxr-xr-x 1 root root 13000 Oct 23 17:32 a.out 4 | -rw-r--r-- 1 root root 2612 Oct 23 01:10 create n process.c 5 | -rw-r--r-- 1 root root 1024 Oct 23 01:11 dup.c 6 | -rw-r--r-- 1 root root 1109 Oct 23 01:11 process_n.c 7 | -------------------------------------------------------------------------------- /GRAPHIC_BASIC/Задание2-OpenGL/Wall.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/GRAPHIC_BASIC/Задание2-OpenGL/Wall.bmp -------------------------------------------------------------------------------- /HASKELL_BASIC/exam/exam18.hs: -------------------------------------------------------------------------------- 1 | import Data.Tuple 2 | 3 | {-- 4 | 1. Text is given. Determine how many words it contains. 5 | --} 6 | textCount :: String -> Int 7 | textCount text = length $ words text 8 | 9 | {-- 10 | 2. 给定的单词。 交换第 m 个和第 n 个字母。 11 | --} 12 | 13 | wordSwap :: Int -> Int -> String -> String 14 | wordSwap m n text = unwords $ swap m n $ words text -------------------------------------------------------------------------------- /HASKELL_BASIC/exam/exam20.hs: -------------------------------------------------------------------------------- 1 | {-- 2 | 1. 按升序对给定的数字列表进行排序,不包括负数。 3 | --} 4 | sortList :: [Int] -> [Int] 5 | sortList [] = [] 6 | sortList (x:xs) = sortList [y | y <- xs, y <= x, y >= 0] ++ [x] ++ sortList [y | y <- xs, y > x, y >= 0] 7 | 8 | {-- 9 | 2. Given a matrix of size NxM ( N>2, M<10). 10 | The elements of the matrix are the numbers 0 and 1. 11 | The allowed operation is the permutation of the columns. 12 | Transform the matrix so that the first row has columns with one in the first row, 13 | then the columns with one in the second row (if any), and so on. 14 | --} 15 | transformMatrix 16 | 17 | -------------------------------------------------------------------------------- /HASKELL_BASIC/exam/t.hs: -------------------------------------------------------------------------------- 1 | import Data.List 2 | -- 1. Given a natural number n and a sequence of integers d1 , d2 , …, dn . Consider segments of this sequence (subsequences of consecutive numbers) consisting of even numbers. Get the largest of the lengths of the considered segments. 3 | 4 | findLongestSequenceOfEvenNumbers :: Int -> [Int] -> Int 5 | findLongestSequenceOfEvenNumbers n ds = maximum $ map length $ filter even $ subsequences ds -------------------------------------------------------------------------------- /HASKELL_BASIC/exam/temp.hs: -------------------------------------------------------------------------------- 1 | import Data.List 2 | {-- 3 | 1. Given a word.Determine how many different letters it contains. 4 | --} 5 | wordLetterCount :: String -> Int 6 | wordLetterCount word = length $ nub word 7 | 8 | {-- 9 | 2. Given a natural number n and integers a1,a2,…,an.Find the number of numbers ai(i=1,2,...,n) that are perfect squares. (Define a function that allows you to recognize full squares.) 10 | --} 11 | perfectSquares :: Int -> [Int] -> Int 12 | perfectSquares n xs = length $ filter (\x -> isSquare x) xs 13 | where isSquare x = (round $ sqrt $ fromIntegral x) ^ 2 == x -------------------------------------------------------------------------------- /HASKELL_BASIC/test1.hs: -------------------------------------------------------------------------------- 1 | doubleMe x = x + x 2 | doubleUs x y = doubleMe x + doubleMe y 3 | -------------------------------------------------------------------------------- /HASKELL_BASIC/test11.hs: -------------------------------------------------------------------------------- 1 | last' :: [a] -> a 2 | last' [] = error "empty list" 3 | last' [x] = x 4 | last' (x:xs) = last' xs 5 | 6 | init' :: [a] -> [a] 7 | init' [] = error "empty list" 8 | init' [x] = [] 9 | init' (x:xs) = x:init'(xs) 10 | 11 | swaps :: Ord a => [a] -> [a] 12 | swaps [] = [] 13 | swaps [x] = [x] 14 | swaps (x1:x2:xs) 15 | | x1 > x2 = x2 : swaps(x1:xs) 16 | | otherwise = x1 : swaps(x2:xs) 17 | 18 | bubblesort :: Ord a => [a] -> [a] 19 | bubblesort [] = [] 20 | bubblesort [x] = [x] 21 | bubblesort xs = bubblesort(init' tmp) ++ [last' tmp] 22 | where 23 | tmp = swaps xs 24 | -------------------------------------------------------------------------------- /HASKELL_BASIC/test16.hs: -------------------------------------------------------------------------------- 1 | maxmin :: Ord a => [a] -> [a] 2 | mainmin [] = [] 3 | maxmin [x] = [x,x] 4 | maxmin [x, y] = if x>y then [x,y] else [y,x] 5 | maxmin (x:y:z:xs) = maxmin(max_min++xs) 6 | where 7 | max_min = maxmin' x y z 8 | 9 | maxmin' x y z 10 | | x >= y && y >= z = [x,z] 11 | | x >= z && z >= y = [x,y] 12 | | y >= x && x >= z = [y,z] 13 | | y >= z && z >= x = [y,x] 14 | | z >= x && x >= y = [z,y] 15 | | z >= y && y >= x = [z,x] -------------------------------------------------------------------------------- /HASKELL_BASIC/test17.hs: -------------------------------------------------------------------------------- 1 | f :: t -> [t] -> [t] 2 | f n [] = [] 3 | f n [x] = [x] 4 | f n (x:xs) = x:n:f n xs 5 | 6 | f' (x:xs) [y] = [y] 7 | f' (x:xs) (y:ys) = y:[x]++xs ++(f' (x:xs) ys) 8 | 9 | -------------------------------------------------------------------------------- /HASKELL_BASIC/test18.hs: -------------------------------------------------------------------------------- 1 | dup :: (t1 -> t -> t1) -> t1 -> [t] -> [t1] 2 | dup f t [] = [] 3 | dup f t (x:xs) = res:dup f res xs 4 | where res = f t x 5 | 6 | newfold :: Eq t1 => (t1 -> t1 -> t1) -> [t1] -> [t1] 7 | newfold f (x:xs) = x : (dup f x xs) 8 | -------------------------------------------------------------------------------- /HASKELL_BASIC/test2.hs: -------------------------------------------------------------------------------- 1 | {-- 2 | test1 :: Float->Float 3 | test1 x = x + x 4 | test2 :: Float->Float->Float 5 | test2 x y = test1 x + test1 y 6 | --} 7 | 8 | {-- 9 | max1 :: (Ord) a => a -> a -> a -> a 10 | max1 x y z 11 | | x >= y && x >= z = x 12 | | y >= x && y >= z = y 13 | | otherwise = z 14 | --} 15 | 16 | max1 :: (Ord) a => a -> a -> a -> a 17 | max1 x y z 18 | | x == max2 x y && x == max2 x z = x 19 | | y == max2 x y && y == max2 y z = y 20 | | z == max2 x z && z == max2 y z = z 21 | 22 | max2 :: (Ord) a => a -> a -> a 23 | max2 x y 24 | | x <= y = y 25 | | otherwise = x 26 | -------------------------------------------------------------------------------- /HASKELL_BASIC/test24.hs: -------------------------------------------------------------------------------- 1 | dup [] = [] 2 | dup (x:xs) = if(x `mod` 2 == 1) then (2*x):dup xs else x:dup xs 3 | -------------------------------------------------------------------------------- /HASKELL_BASIC/test3.hs: -------------------------------------------------------------------------------- 1 | lucky :: (Integral a) => a -> String 2 | lucky 7 = "lucky number!" 3 | lucky x = "Sorry!" 4 | -------------------------------------------------------------------------------- /HASKELL_BASIC/test5.hs: -------------------------------------------------------------------------------- 1 | del :: (Eq)a=>a->[a]->[a] 2 | del cxd [] = [] 3 | del cxd (x:xs) 4 | | cxd == x = del cxd xs 5 | | otherwise = x : del cxd xs 6 | del_dup :: (Eq)t=>[t]->[t] 7 | del_dup [] = [] 8 | del_dup (x:xs) = x:del_dup (del x xs) 9 | 10 | del_dup_t :: (Eq)t=>[t]->[t] 11 | del_dup_t [] = [] 12 | del_dup_t (x:xs) 13 | | del x xs == xs = x:del_dup_t xs 14 | | otherwise = del_dup_t (del x xs) 15 | -------------------------------------------------------------------------------- /HASKELL_BASIC/test7.hs: -------------------------------------------------------------------------------- 1 | mygates::[a] 2 | -------------------------------------------------------------------------------- /HASKELL_BASIC/test8.hs: -------------------------------------------------------------------------------- 1 | filter1 :: (a -> Bool) -> [a] -> [a] 2 | filter1 _[]=[] 3 | filter1 b (x:xs) 4 | | b x = x : filter1 b xs 5 | | otherwise = filter1 b xs 6 | 7 | mapmy :: (a -> b) -> [a] -> [b] 8 | mapmy _[] = [] 9 | mapmy f (x:xs) = f x:mapmy f xs 10 | 11 | --reverse_f x f1 f2 = f2(f1 x) 12 | reverse_f x f1 f2 = f2$f1$x 13 | -------------------------------------------------------------------------------- /INSECON/task1/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | services: 4 | nginx: 5 | image: nginx:latest 6 | volumes: 7 | - ./nginx:/etc/nginx 8 | ports: 9 | - "443:443" 10 | - "80:80" 11 | -------------------------------------------------------------------------------- /INSECON/task2/ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | curl \ 4 | -X POST \ 5 | -d 'ip=localhost+%7C+ls&Submit=Submit' \ 6 | --user-agent "lisy-ci" \ 7 | -v http://dvwa.rerand0m.ru/vulnerabilities/exec/ \ 8 | -b'security=low;PHPSESSID=419h04sqpgrbl8br0gtcldunn5' 9 | -------------------------------------------------------------------------------- /INSECON/task2/sqli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | curl \ 4 | --user-agent "lisy-sqli" \ 5 | -v http://dvwa.rerand0m.ru/vulnerabilities/sqli/\?id\=%25%27+or+%270%27%3D%270\&Submit\=Submit\# \ 6 | -b'PHPSESSID=d0dr5dqj0i8pagpoettd1hua23;security=low' -------------------------------------------------------------------------------- /INSECON/task2/zip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | NAME=lisy 3 | GROUP=628 4 | 5 | zip -r $NAME-$GROUP-p2.zip \ 6 | $NAME-ci.pcap \ 7 | $NAME-sqli.pcap 8 | -------------------------------------------------------------------------------- /INSECON/task3/task3.1/acl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | NAME=lisy 4 | 5 | PORT=3128 6 | HOST=localhost 7 | PROXY=$HOST:$PORT 8 | 9 | DEFAULT_CONFIG=squid.conf.default 10 | ACL_CONFIG=acl.conf 11 | 12 | cp $DEFAULT_CONFIG $ACL_CONFIG 13 | cat >>$ACL_CONFIG <>$UA_CONFIG < 0 && b > 0); 6 | do 7 | :: x > y -> x = x - y 8 | :: x < y -> y = y - x 9 | :: else -> break 10 | od 11 | printf("gcd(%d,%d)=%d\n", a, b, x); 12 | } 13 | 14 | init { 15 | run euclid(25, 5); 16 | run euclid(33, 11); 17 | run euclid(19, 17); 18 | } 19 | -------------------------------------------------------------------------------- /MODEL_CHECKING/CLASS/PROMELA/main.pml: -------------------------------------------------------------------------------- 1 | active proctype main() { 2 | printf("Hello World: %d\n", _pid); 3 | } 4 | -------------------------------------------------------------------------------- /MODEL_CHECKING/CLASS/PROMELA/mutual_exclusion.pml: -------------------------------------------------------------------------------- 1 | #define MUTEX_ENABLED 2 | 3 | #define N 20 4 | 5 | byte count = 0; 6 | byte mutex = 1; 7 | 8 | inline lock() { 9 | atomic { mutex > 0 -> mutex-- } 10 | } 11 | 12 | inline unlock() { 13 | mutex++ 14 | } 15 | 16 | active [N] proctype P() { 17 | NCS: printf("NCS\n"); 18 | SET: 19 | #ifdef MUTEX_ENABLED 20 | lock(); 21 | #endif 22 | CRS: count++; 23 | printf("CRS\n"); 24 | RST: count--; 25 | #ifdef MUTEX_ENABLED 26 | unlock(); 27 | #endif 28 | goto NCS; 29 | } 30 | 31 | ltl MutualExclusion { 32 | [](count <= 1) 33 | } 34 | -------------------------------------------------------------------------------- /MODEL_CHECKING/CLASS/PROMELA/peterson.pml: -------------------------------------------------------------------------------- 1 | #define N 2 2 | 3 | bool flag[N] = 0; 4 | byte turn = 0; 5 | 6 | active [N] proctype P() { 7 | byte i = _pid; 8 | assert(0 <= i && i <= 1); 9 | NCS: printf("NCS%d\n", i); 10 | SET: flag[i] = 1; turn = i; 11 | TST: !((flag[1-i] == 1) && (turn == i)); 12 | CRS: printf("CRS%d\n", i); 13 | RST: flag[i] = 0; goto NCS; 14 | } 15 | 16 | ltl safety { 17 | [](!(P[0]@CRS && P[1]@CRS)) 18 | } 19 | 20 | ltl liveness { 21 | [](P[0]@SET -> <>(P[0]@CRS)) 22 | } 23 | -------------------------------------------------------------------------------- /MODEL_CHECKING/CLASS/PROMELA/ping_pong.pml: -------------------------------------------------------------------------------- 1 | #define N 16 2 | 3 | chan c = [1] of {byte /* PID */, int /* DATA */}; 4 | 5 | active [2] proctype P() { 6 | int i; 7 | 8 | if 9 | :: (_pid == 0) -> c!0,0 10 | :: else 11 | fi 12 | 13 | do 14 | :: c?eval(1 - _pid),i -> atomic { 15 | c!_pid,(i + 1) % N; 16 | printf("%d: %d\n", _pid, i); 17 | } 18 | od 19 | } 20 | 21 | active proctype WatchDog() { 22 | do 23 | :: timeout -> assert(false) 24 | od 25 | } 26 | 27 | -------------------------------------------------------------------------------- /MODEL_CHECKING/PRAC/TASK1/README.md: -------------------------------------------------------------------------------- 1 | # LTL_TO_AUTOMATON 2 | Run the following command to run the program with the given test cases: 3 | ```bash 4 | ./run.sh 5 | ``` -------------------------------------------------------------------------------- /MODEL_CHECKING/PRAC/TASK1/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | clean_project() { 4 | rm -rf build 5 | } 6 | 7 | build_project() { 8 | cmake -B build && cmake --build build 9 | } 10 | 11 | run_tests() { 12 | cd build && ctest --verbose 13 | } 14 | 15 | if [ "$1" == "clean" ]; then 16 | clean_project 17 | elif [ "$1" == "build" ]; then 18 | clean_project && build_project 19 | elif [ "$1" == "test" ]; then 20 | build_project && run_tests 21 | else 22 | clean_project && build_project && run_tests 23 | fi -------------------------------------------------------------------------------- /MODEL_CHECKING/PRAC/TASK2/Makefile: -------------------------------------------------------------------------------- 1 | SOURCE=bdd.cpp formula.cpp test.cpp 2 | TARGET=test 3 | 4 | CFLAGS = -I. -Wall -std=c++17 5 | 6 | all: $(TARGET) 7 | 8 | $(TARGET): $(SOURCE) 9 | g++ $(CFLAGS) -o $@ -I. $^ 10 | 11 | run: 12 | ./$(TARGET) 13 | 14 | clean: 15 | rm -rf $(TARGET) 16 | 17 | -------------------------------------------------------------------------------- /MODEL_CHECKING/PRAC/TASK3/README.md: -------------------------------------------------------------------------------- 1 | # SAT Solver by using DPLL algorithm 2 | 3 | ### Usage 4 | ``` bash 5 | make run 6 | ``` 7 | 8 | ### Test result (Apple M1 Pro 3.22 GHz) 9 | ```bash 10 | Test for tests/sat/uf50-218 took 2.124 seconds 11 | 12 | Test for tests/sat/aim took 0.01 seconds 13 | 14 | Test for tests/sat/hanoi took 484.901 seconds 15 | 16 | Test for tests/unsat/aim took 0.025 seconds 17 | 18 | Test for tests/unsat/UUF50.218.1000 took 4.431 seconds 19 | 20 | Test for tests/unsat/pigeon-hole took 62.606 seconds 21 | ``` 22 | ## [Tests data source](https://www.cs.ubc.ca/~hoos/SATLIB/benchm.html) -------------------------------------------------------------------------------- /R_BASIC/.Rhistory: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/.Rhistory -------------------------------------------------------------------------------- /R_BASIC/9.1.R: -------------------------------------------------------------------------------- 1 | fx<-1/(2-(-2)) 2 | fx 3 | 4 | f1<-function(x) (fx*x) 5 | Ex<-integrate(f1, lower = -2, upper = 2) 6 | Ex$value 7 | 8 | f2<-function(x) (fx*(x-Ex$value)^2) 9 | Dx<-integrate(f2, lower = -2, upper = 2) 10 | Dx$value -------------------------------------------------------------------------------- /R_BASIC/9.2.R: -------------------------------------------------------------------------------- 1 | set.seed(16) 2 | N<-100 3 | data<-runif(N, -2, 2) 4 | plot(data, type = 'l') 5 | 6 | sr_data<-mean(data) #E[X] 7 | dis_data<-var(data) #D[X] 8 | 9 | -------------------------------------------------------------------------------- /R_BASIC/9.3.R: -------------------------------------------------------------------------------- 1 | m<-0 2 | sigma<-1 3 | 4 | # exp2 <- function (x) { 5 | # (2*pi)^(-0.5)*exp(-(x-m)^2/(2*sigma^2)) 6 | # } 7 | 8 | exp2 <- function(x) { 9 | (1/((2*pi)^(0.5)*sigma))*exp(-(x-m)^2/(2*sigma^2)) 10 | } 11 | curve(exp2, -3, 3) 12 | plot(exp2, -10, 10) 13 | 14 | int_exp2<-integrate(function(x) exp2(x), lower = -10, upper = 10) 15 | int_exp2$value 16 | -------------------------------------------------------------------------------- /R_BASIC/DJIA.R: -------------------------------------------------------------------------------- 1 | # 2 | #индекс Доу Джонса 3 | # и ставка LIBOR 3 мес 4 | require(quantmod) 5 | getSymbols("DJIA",src="FRED") 6 | plot.xts(DJIA,main="DJIA") 7 | dj<-DJIA['2020-01-01/'] 8 | chartSeries(dj,name="DJIA") 9 | dj_ya<-getSymbols("^DJI",src="yahoo") 10 | ns_ya<-getSymbols("^IXIC",src="yahoo") 11 | 12 | # LIBOR 3 mnth 13 | #USD3MTD156N 14 | getSymbols('USD3MTD156N',src='FRED') 15 | head(USD3MTD156N) 16 | str(USD3MTD156N) 17 | sample.xts=USD3MTD156N['2007-04-01/'] 18 | sample1.xts=USD3MTD156N['2020-04-01/'] 19 | plot.xts(sample.xts) 20 | plot.xts(sample1.xts) 21 | chartSeries(sample1.xts,name="LIBOR") 22 | -------------------------------------------------------------------------------- /R_BASIC/Zan11/grBin.R: -------------------------------------------------------------------------------- 1 | par(mfrow=c(1,2), pty="m") #задает параметры для графиков 1, 2 квадратные 2 | plot(0:8, dbinom(0:8,8,0.3), type="h", xlab="x", ylab="P(X=x)", xlim=c(-1,9)) 3 | title("PDF for X~Bin(8, 0.3)") 4 | 5 | plot(0:8, pbinom(0:8,8,0.3), type="n", xlab="x", ylab="F(x)", 6 | xlim=c(-1,9), ylim=c(0,1)) 7 | #segments(-1,0,0,0) 8 | #segments(0:8, pbinom(0:8,8,.3), 1:9, pbinom(0:8,8,.3)) 9 | lines(0:7, pbinom(0:7,8,.3), type="p", pch=16) 10 | segments(-1,1,9,1, lty=2) 11 | title("CDF for X~Bin(8, 0.3)") -------------------------------------------------------------------------------- /R_BASIC/Zan11/grBinN.R: -------------------------------------------------------------------------------- 1 | par(mfrow=c(1,2), pty="m") #задает параметры для графиков 1, 2 квадратные 2 | N<-200 3 | p<-0.8 4 | 5 | plot(0:N, dbinom(0:N,N,p), type="h", xlab="x", ylab="P(X=x)", xlim=c(-1,N+1)) 6 | title("PDF for X~Bin(N, p)") 7 | 8 | plot(0:N, pbinom(0:N,N,p), type="n", xlab="x", ylab="F(x)", 9 | xlim=c(-1,N+1), ylim=c(0,1)) 10 | segments(-1,0,0,0) 11 | segments(0:N, pbinom(0:N,N,p), 1:N+1, pbinom(0:N,N,p)) 12 | lines(0:N-1, pbinom(0:N-1,N,p), type="p", pch=16) 13 | segments(-1,1,9,1, lty=2) 14 | title("CDF for X~Bin(N, p)") -------------------------------------------------------------------------------- /R_BASIC/Zan11/grNor.R: -------------------------------------------------------------------------------- 1 | # 2 | #нарисуем график нормального распределения N(m,sigma) 3 | # 4 | m<-0 5 | sigma<-1 6 | exp2 <- function(x) (2*pi)^(-0.5)*exp(-(x-m)^2/(2*sigma^2)) 7 | 8 | curve(exp2, -3, 3, n = 200) 9 | plot (exp2, -10, 10, n = 200) 10 | 11 | # 12 | # проинтергрируем -10 до 10 13 | # 14 | int_exp2<-integrate(function(x) exp2(x), lower = -10, upper = 10) 15 | int_exp2 16 | #1 with absolute error < 7.4e-05 -------------------------------------------------------------------------------- /R_BASIC/Zan12/quantmod.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan12/quantmod.pdf -------------------------------------------------------------------------------- /R_BASIC/Zan12/returnApple.R: -------------------------------------------------------------------------------- 1 | # вычисление доходности и построение гистограммы 2 | #install.packages('quantmod') 3 | library('quantmod') 4 | #install.packages('forecast') 5 | library('forecast') 6 | library('xts') 7 | 8 | #library(quantmod); library(xts) 9 | 10 | Sys.setlocale("LC_TIME","C") 11 | 12 | 13 | getSymbols("AAPL",src="yahoo") 14 | ap1<-AAPL['2021-01-01/'] 15 | pr.close<-AAPL$AAPL.Close['2021-01-01/'] 16 | head(ap1) 17 | plot.xts(pr.close) 18 | chartSeries(ap1,name="APPLE in $USD") 19 | barChart(ap1) 20 | -------------------------------------------------------------------------------- /R_BASIC/Zan14/.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan14/.RData -------------------------------------------------------------------------------- /R_BASIC/Zan14/14.1.R: -------------------------------------------------------------------------------- 1 | m<-7 2 | sgm<-3 3 | exp22 <- function(x) {(2*pi*sgm^2)^(-0.5)*exp(-(x-m)^2/(2*sgm^2))} 4 | curve(exp22, -2, 16, n = 100) 5 | 6 | int_exp22<-integrate(function(x) exp22(x), lower = 7.1, upper = +Inf) 7 | int_exp22 # P(X > 7.1) 8 | 9 | p<-0.8 10 | k<-qnorm(p, mean=m, sd=sgm) 11 | k # P(X < k) = 0.8 -------------------------------------------------------------------------------- /R_BASIC/Zan14/14.2.R: -------------------------------------------------------------------------------- 1 | m<-3 2 | sgm<-0.5 3 | exp22 <- function(x) {(2*pi*sgm^2)^(-0.5)*exp(-(x-m)^2/(2*sgm^2))} 4 | curve(exp22, 1.5, 4.5, n = 100) 5 | 6 | int_exp22<-integrate(function(x) exp22(x), lower = 3.5, upper = +Inf) 7 | int_exp22 # P(X > 3.5) 8 | -------------------------------------------------------------------------------- /R_BASIC/Zan14/AAPL_DJI_CLOSE.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan14/AAPL_DJI_CLOSE.pdf -------------------------------------------------------------------------------- /R_BASIC/Zan14/gr3Dim.R: -------------------------------------------------------------------------------- 1 | #график 2 мерной плотности распределения случайного вектора 2 | function.draw <- function(f, low=-1, hi=1, n=30){ 3 | r <- seq(low, hi, length=n) 4 | z <- outer (r, r, f) 5 | persp(r, r, z, xlab="X", ylab="Y", zlab="Z")} 6 | 7 | #f3 <- function(x, y) {ifelse(x >= y, 8*x*y, 0)} 8 | m<-0 9 | sgm<-1 10 | 11 | f3 <- function(x, y) {(2*pi*sgm^2)*exp((-((x-m)^2+(y-m)^2))/(2*sgm^2))} 12 | 13 | 14 | function.draw(f3,-3,3,25) 15 | 16 | -------------------------------------------------------------------------------- /R_BASIC/Zan14/grNorm.R: -------------------------------------------------------------------------------- 1 | # 2 | #нарисуем график нормального распределения N(m,sigma) 3 | # 4 | m<-0 5 | sgm<-1 6 | exp22 <- function(x) {(2*pi*sgm^2)^(-0.5)*exp(-(x-m)^2/(2*sgm^2))} 7 | #exp3 <- function(x) 1/sigma*(2*pi)^(-0.5)*exp(-(x-m)^2/(2*sigma^2)) 8 | curve(exp22, -3, 3, n = 100) 9 | 10 | # 11 | # проинтегрируем -10 до p 12 | # 13 | int_exp22<-integrate(function(x) exp22(x), lower = -3, upper = 0) 14 | int_exp22 15 | # 16 | #0.4986501 with absolute error < 5.5e-15 17 | p<-0.5 18 | 19 | qnorm(p, mean=m, sd=sgm) 20 | #[1] 0 21 | -------------------------------------------------------------------------------- /R_BASIC/Zan15/AR1.inp: -------------------------------------------------------------------------------- 1 | scalar alfa=0.2 2 | scalar sigma=1.0 3 | series y=0 4 | series epsilon=randgen(n,0,1) 5 | series epsilon1=randgen(n,0,0.1) 6 | smpl 2 500 7 | y=alfa*y(-1)+epsilon 8 | -------------------------------------------------------------------------------- /R_BASIC/Zan15/ARMA.m: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan15/ARMA.m -------------------------------------------------------------------------------- /R_BASIC/Zan15/Graph_y1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan15/Graph_y1.png -------------------------------------------------------------------------------- /R_BASIC/Zan15/Graph_y2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan15/Graph_y2.png -------------------------------------------------------------------------------- /R_BASIC/Zan15/Graph_y3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan15/Graph_y3.png -------------------------------------------------------------------------------- /R_BASIC/Zan15/Homework15_2.R: -------------------------------------------------------------------------------- 1 | # генерация y=ax+b x-нормально распред. 2 | set.seed(16) 3 | N<-100 4 | m1<-0 5 | s1<-1 6 | data <- rnorm(N, m1, s1) 7 | plot(data,type='l', main = 'график y=ax+b') 8 | 9 | # 10 | # среднее значение 11 | # 12 | 13 | sr_data<-mean(data) 14 | sr_data 15 | dis_data<-var(data) 16 | dis_data 17 | #[1] 0.05958278 18 | # [1] 1.016086 19 | 20 | x<-data 21 | eps1<-rnorm(N, m1, s1) 22 | 23 | #random number a, b, sg1 24 | a<-runif(1,-2,2) 25 | b<-runif(1,-1,1) 26 | sg1<-runif(1,0,1) 27 | 28 | y<-a*x+b+sg1*eps1 29 | plot(x,type='l', main = 'график y=ax+b+eps') 30 | i<-1:100 31 | i=seq(1,100) 32 | 33 | points(i,y,type="l",lty=2) -------------------------------------------------------------------------------- /R_BASIC/Zan15/gr_1.m: -------------------------------------------------------------------------------- 1 | x = -10:0.1:10; # Create an evenly-spaced vector from -10..10 2 | y = sin (x); # y is also a vector 3 | plot (x, y); 4 | title ("Simple 2-D Plot"); 5 | xlabel ("x"); 6 | ylabel ("sin (x)"); -------------------------------------------------------------------------------- /R_BASIC/Zan15/mat1.m: -------------------------------------------------------------------------------- 1 | b = [4; 9; 2] # Column vector 2 | A = [ 3 4 5; 3 | 1 3 1; 4 | 3 5 9 ] 5 | x = A \ b # Solve the system Ax = b -------------------------------------------------------------------------------- /R_BASIC/Zan16/Homework16.R: -------------------------------------------------------------------------------- 1 | # ARIMA -модель . 2 | library("ggplot2") # графики 3 | library("forecast") # прогнозирование временных рядов: ARMA 4 | library("xts") # операции с временными рядами 5 | set.seed(16) 6 | y <- arima.sim(n = 100, list(order = c(1,0,0),ar = 0.7)) 7 | ggtsdisplay(y) 8 | set.seed(16) 9 | y1 <- arima.sim(list(order = c(1,0,0), ar = 0.7), n = 100 ) 10 | ts.plot(y1) 11 | set.seed(16) 12 | y2 <- arima.sim(list(order = c(1,0,0), ar = 0.7), n = 100, sd =12 ) 13 | ts.plot(y2) -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/Answer1/Matrix_bonds_1.txt: -------------------------------------------------------------------------------- 1 | 110.75 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 2 | 10.00 110.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 3 | 5.25 5.25 105.25 0.00 0.00 0.00 0.00 0.00 0.00 0.00 4 | 7.88 7.88 7.88 107.88 0.00 0.00 0.00 0.00 0.00 0.00 5 | 12.80 12.80 12.80 12.80 112.80 0.00 0.00 0.00 0.00 0.00 6 | 8.25 8.25 8.25 8.25 8.25 108.25 0.00 0.00 0.00 0.00 7 | 10.25 10.25 10.25 10.25 10.25 10.25 110.25 0.00 0.00 0.00 8 | 5.63 5.63 5.63 5.63 5.63 5.63 5.63 105.63 0.00 0.00 9 | 8.38 8.38 8.38 8.38 8.38 8.38 8.38 8.38 108.38 0.00 10 | 8.38 8.38 8.38 8.38 8.38 8.38 8.38 8.38 8.38 108.38 11 | -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/Answer1/Matrix_bonds_2.txt: -------------------------------------------------------------------------------- 1 | 104.75 0.00 0.00 0.00 0.00 0.00 2 | 5.00 105.00 0.00 0.00 0.00 0.00 3 | 5.15 5.15 105.15 0.00 0.00 0.00 4 | 5.45 5.45 5.45 105.45 0.00 0.00 5 | 6.15 6.15 6.15 6.15 106.15 0.00 6 | 8.25 8.25 8.25 8.25 8.25 108.25 7 | -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/Answer1/Matrix_plot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan8/Homework/Answer1/Matrix_plot_1.png -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/Answer1/Matrix_plot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan8/Homework/Answer1/Matrix_plot_2.png -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/Answer1/Matrix_price_1.txt: -------------------------------------------------------------------------------- 1 | 103.72 2 | 103.74 3 | 92.49 4 | 98.40 5 | 116.90 6 | 99.56 7 | 108.66 8 | 83.54 9 | 99.34 10 | 99.29 11 | -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/Answer1/Matrix_price_2.txt: -------------------------------------------------------------------------------- 1 | 100.60 2 | 100.10 3 | 99.85 4 | 98.82 5 | 100.64 6 | 109.48 7 | -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/Answer1/OLSdannyeBonds_1.R: -------------------------------------------------------------------------------- 1 | library(MASS) 2 | mBonds=(read.table("Matrix_bond_1.txt")) 3 | mBonds 4 | mPrice<-read.table("Matrix_price_1.txt") 5 | mPrice 6 | 7 | mB<-(as.matrix(mBonds)) 8 | mB 9 | mP<-(as.matrix(mPrice)) 10 | mP 11 | mBT<-t(mB) 12 | mB<-mBT%*%mB 13 | mB 14 | mP<-mBT%*%mP 15 | mP 16 | 17 | discontFact<- ginv(mB)%*%mP 18 | discontFact 19 | ir_curve<-c(rep(0,10)) 20 | for(i in (1:10)){ 21 | ir_curve[i]=(1/discontFact[i])^(1/i)-1 22 | 23 | } 24 | 25 | ir_curve 26 | plot(ir_curve, type = 'b') 27 | -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/Answer1/OLSdannyeBonds_2.R: -------------------------------------------------------------------------------- 1 | library(MASS) 2 | mBonds=(read.table("Matrix_bond_2.txt")) 3 | mBonds 4 | mPrice<-read.table("Matrix_price_2.txt") 5 | mPrice 6 | 7 | mB<-(as.matrix(mBonds)) 8 | mB 9 | mP<-(as.matrix(mPrice)) 10 | mP 11 | mBT<-t(mB) 12 | mB<-mBT%*%mB 13 | mB 14 | mP<-mBT%*%mP 15 | mP 16 | 17 | discontFact<- ginv(mB)%*%mP 18 | discontFact 19 | ir_curve<-c(rep(0,6)) 20 | for(i in (1:6)){ 21 | ir_curve[i]=(1/discontFact[i])^(1/i)-1 22 | 23 | } 24 | 25 | ir_curve 26 | plot(ir_curve, type = 'b') 27 | -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/Answer2/.Rhistory: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan8/Homework/Answer2/.Rhistory -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/Answer2/Reg.txt: -------------------------------------------------------------------------------- 1 | 1 0 0 0 0 0 0 0 0 0 2 | 0 1 0 0 0 0 0 0 0 0 3 | 0 0 0 0 0 0 0 0 0 0 4 | 0 0 0 1 0 0 0 0 0 0 5 | 0 0 0 0 1 0 0 0 0 0 6 | 0 0 0 0 0 0 0 0 0 0 7 | 0 0 0 0 0 0 1 0 0 0 8 | 0 0 0 0 0 0 0 1 0 0 9 | 0 0 0 0 0 0 0 0 1 0 10 | 0 0 0 0 0 0 0 0 0 0 -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/NS.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan8/Homework/NS.R -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/NelsonSig.R: -------------------------------------------------------------------------------- 1 | library(YieldCurve) 2 | data(FedYieldCurve) 3 | rate.Fed = first(FedYieldCurve,'5 month') 4 | 5 | maturity.Fed <- c(1/12, 0.5, 1,2,3,5,8,13) 6 | NSParameters <- Nelson.Siegel( rate= rate.Fed, maturity=maturity.Fed ) 7 | y <- NSrates(NSParameters[5,], maturity.Fed) 8 | plot(maturity.Fed,rate.Fed[5,],main="Fitting Nelson-Siegel yield curve", type="o") 9 | lines(maturity.Fed,y, col=2) 10 | legend("topleft",legend=c("observed yield curve","fitted yield curve"), 11 | col=c(1,2),lty=1) 12 | 13 | -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/xtsCr.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan8/Homework/xtsCr.R -------------------------------------------------------------------------------- /R_BASIC/Zan8/Homework/Занятие 8.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan8/Homework/Занятие 8.xlsx -------------------------------------------------------------------------------- /R_BASIC/Zan8/NS.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan8/NS.R -------------------------------------------------------------------------------- /R_BASIC/Zan8/NelsonSig.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan8/NelsonSig.R -------------------------------------------------------------------------------- /R_BASIC/Zan8/OLSdannyeBonds.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan8/OLSdannyeBonds.R -------------------------------------------------------------------------------- /R_BASIC/Zan8/OLSdannyeBondsReg.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan8/OLSdannyeBondsReg.R -------------------------------------------------------------------------------- /R_BASIC/Zan8/xtsCr.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/Zan8/xtsCr.R -------------------------------------------------------------------------------- /R_BASIC/app_durattion1.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/app_durattion1.R -------------------------------------------------------------------------------- /R_BASIC/approx_conv.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/approx_conv.R -------------------------------------------------------------------------------- /R_BASIC/approx_duration.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/approx_duration.R -------------------------------------------------------------------------------- /R_BASIC/bondDuration.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/bondDuration.R -------------------------------------------------------------------------------- /R_BASIC/bondPrice_r.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/bondPrice_r.R -------------------------------------------------------------------------------- /R_BASIC/bondPrice_r_convex.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/bondPrice_r_convex.R -------------------------------------------------------------------------------- /R_BASIC/bondconv_i.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/bondconv_i.R -------------------------------------------------------------------------------- /R_BASIC/bondconv_r.R: -------------------------------------------------------------------------------- 1 | # 2 | #?????????? ?????????? 3 | #convexity 4 | 5 | # ???????????? ????????? r - ???? ???????? 6 | bondconv_r <- function(p, cr, ttm, r) { 7 | cf <- c(rep(p * cr, times=ttm - 1), p * (1 + cr)) 8 | cf <- data.frame(cf) 9 | cf$t <- as.numeric(rownames(cf)) 10 | cf$pv_factor <- exp(-r*cf$t) 11 | cf$pv <- cf$cf * cf$pv_factor*cf$t^2 12 | sum(cf$pv)/bondprc_r(p, cr, ttm, r) 13 | } 14 | 15 | i=0.1 16 | r1<-log(1+i) 17 | c1<-bondconv_r(100, 0.1, 5, r=r1) 18 | c1 19 | -------------------------------------------------------------------------------- /R_BASIC/datFR.R: -------------------------------------------------------------------------------- 1 | #set.seed(0) 2 | options(digits =1) 3 | df <-data.frame(id = LETTERS[1:6], 4 | age =runif(6, 24, 30), 5 | height =rnorm(6, 170, 2)) 6 | df 7 | df$height 8 | is.vector(df$height) 9 | df$age -------------------------------------------------------------------------------- /R_BASIC/duration2years.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/duration2years.R -------------------------------------------------------------------------------- /R_BASIC/exampleDF.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/exampleDF.R -------------------------------------------------------------------------------- /R_BASIC/fromWB.R: -------------------------------------------------------------------------------- 1 | library(tidyverse) 2 | library(wbstats) 3 | # search for a dataset of interest 4 | #df1_bond<-wb_search(pattern ="bond") %>% head 5 | df1_bond<-wb_search(pattern ="bond") 6 | df1_ed<-wb_search(pattern = "education") 7 | df1_bond %>% head -------------------------------------------------------------------------------- /R_BASIC/ger_UniF.R: -------------------------------------------------------------------------------- 1 | # генерация 100 равномерно распределнных СВ 2 | set.seed(16) 3 | N<-1000000 4 | a<-3 5 | b<-4 6 | data <- runif(N, a, b) 7 | #plot(data,type='l') 8 | # 9 | # среднее значение 10 | # 11 | sr_data<-mean(data) 12 | dis_data<-var(data) 13 | # 4/3 14 | #[1] 1.333333 15 | # ожидание (b+a)/2 16 | # дисперсия (b-a)^2/12 17 | -------------------------------------------------------------------------------- /R_BASIC/grNor.R: -------------------------------------------------------------------------------- 1 | # 2 | #нарисуем график нормального распределения N(0,1) 3 | # 4 | m<-0 5 | sigma<-3 6 | exp2 <- function(x) (2*pi)^(-0.5)*exp(-(x-m)^2/(2*sigma^2)) 7 | 8 | curve(exp2, -3, 3, n = 200) 9 | plot (exp2, -10, 10, n = 200) 10 | 11 | # 12 | # проинтергрируем -10 до 10 13 | # 14 | int_exp2<-integrate(function(x) exp2(x), lower = -10, upper = 10) 15 | int_exp2 16 | #1 with absolute error < 7.4e-05 -------------------------------------------------------------------------------- /R_BASIC/grSinDuration.R: -------------------------------------------------------------------------------- 1 | duration<-function (i, cupon, n, t) 2 | { 3 | t_f<-seq(from = 1, to = n) 4 | d=1/(1+i) 5 | 6 | d_f=d^t_f; 7 | c_f=seq(1,1,n) 8 | c_f=cupon*c_f 9 | cur_val=sum(d_f*c_f)+1*d^n 10 | 11 | return(cur_val) 12 | } 13 | 14 | 15 | plot(sin, -pi, 2*pi) # see ?plot.function 16 | 17 | sincosexp <- function(x) sin(cos(x)*exp(-x/2)) 18 | curve(sincosexp, 4, 17, n = 200) 19 | plot (sincosexp, -17, -4, n = 200) 20 | 21 | duration(0.1,0.1,10,1) 22 | -------------------------------------------------------------------------------- /R_BASIC/importAAPL_XPT.R: -------------------------------------------------------------------------------- 1 | #install.packages('quantmod') 2 | library('quantmod') 3 | #install.packages('forecast') 4 | library('forecast') 5 | library('xts') 6 | 7 | #library(quantmod); library(xts) 8 | 9 | Sys.setlocale("LC_TIME","C") 10 | 11 | 12 | getSymbols("AAPL",src="yahoo") 13 | ap1<-AAPL['2021-01-01/'] 14 | chartSeries(ap1,name="APPLE in $USD") 15 | #barChart(AAPL) 16 | getSymbols("XPT/USD",src="oanda") 17 | chartSeries(XPTUSD,name="Platinum (.oz) in $USD") -------------------------------------------------------------------------------- /R_BASIC/nerChebysh.R: -------------------------------------------------------------------------------- 1 | x <- 0:3 2 | px <- c(1/8,3/8,3/8,1/8) 3 | EX <- weighted.mean(x, px) 4 | EX2 <- weighted.mean(x^2, px) 5 | VX <- EX2 - EX^2 6 | sigmaX <- sqrt(VX) 7 | c(EX, EX2, VX, sigmaX) 8 | #[1] 1.5000000 3.0000000 0.7500000 0.8660254 9 | -------------------------------------------------------------------------------- /R_BASIC/priceYield.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/priceYield.R -------------------------------------------------------------------------------- /R_BASIC/probUnit.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/probUnit.R -------------------------------------------------------------------------------- /R_BASIC/pv12.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/pv12.R -------------------------------------------------------------------------------- /R_BASIC/returnApple/result.txt: -------------------------------------------------------------------------------- 1 | > mean(apRd) 2 | [1] 0.001048118 3 | > mean(apRw) 4 | [1] 0.005053476 5 | > mean(apRm) 6 | [1] 0.0218886 7 | > mean(apRq) 8 | [1] 0.06491103 9 | > mean(apRy) 10 | [1] 0.2509893 11 | ================================= 12 | > sd(apRd) 13 | [1] 0.02055791 14 | > sd(apRw) 15 | [1] 0.04402732 16 | > sd(apRm) 17 | [1] 0.09201089 18 | > sd(apRq) 19 | [1] 0.1714664 20 | > sd(apRy) 21 | [1] 0.4293524 22 | -------------------------------------------------------------------------------- /R_BASIC/testFunc.R: -------------------------------------------------------------------------------- 1 | myFunction <- function () { 2 | print ('myFunction!') 3 | } 4 | demoFunction <- function (a, b, c) { 5 | cat ('a=', a, 'b=', b, 'c=', c) 6 | } 7 | sumFunction <- function (a, b, c) { 8 | sum = a + b + c 9 | return (sum) 10 | } 11 | myFunction() 12 | 13 | demoFunction(1,2,3) 14 | 15 | sumFunction(1,2,6) 16 | -------------------------------------------------------------------------------- /R_BASIC/typeMatrx.R: -------------------------------------------------------------------------------- 1 | ma <-matrix(letters[1:12], nrow =4, 2 | dimnames =list(c('row1', 'row2', 'row3','row4'), 3 | c('c1', 'c2', 'c3'))) 4 | ma 5 | 6 | mrb <-rbind(c(3, 5, 7), c(4, 6, 8)) 7 | mrb 8 | 9 | mrb <-cbind(c(3, 5, 7), c(4, 6, 8)) 10 | mrb 11 | -------------------------------------------------------------------------------- /R_BASIC/typeVec.R: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/R_BASIC/typeVec.R -------------------------------------------------------------------------------- /R_BASIC/typeVector.R: -------------------------------------------------------------------------------- 1 | v1<-numeric(length=4) 2 | v3<-vector(mode= "numeric", length=4) 3 | v1 4 | v3 5 | 6 | l1 <- list(c(1, 5, 7), "string", c(TRUE, FALSE)) 7 | l1 8 | v <- numeric(6) 9 | v<-c(1,2,3,4,5) 10 | v2 <- numeric(6) 11 | v2<-c(1,2,3,4,5,6);v2 12 | 13 | dim(v2) <- c(2, 3); v2 14 | dim(v2) <- c(3, 2); v2 15 | v3 -------------------------------------------------------------------------------- /R_BASIC/wbSearch.R: -------------------------------------------------------------------------------- 1 | library(tidyverse) 2 | library(wbstats) 3 | 4 | # наборы данных на сайте World Bank 5 | # тестовая программа 6 | #df1_bond<-wb_search(pattern ="bond") %>% head 7 | df1_bond<-wb_search(pattern ="bond") 8 | df1_ed<-wb_search(pattern = "education") 9 | 10 | df1_bond %>% head 11 | 12 | 13 | df1_ed %>% tail -------------------------------------------------------------------------------- /R_BASIC/yieldBond.R: -------------------------------------------------------------------------------- 1 | # Вектор денежного потока cash flow vector 2 | cf <- c(-95.79, 5, 5, 5, 5, 105) 3 | 4 | # короткая программа для оценки приведенной стоимости valuation function 5 | bval <- function(i, cf, 6 | t=seq(along = cf)) 7 | sum(cf / (1 + i)^t) 8 | 9 | # Находим доходность к погашению ytm() function using uniroot 10 | ytm <- function(cf) { 11 | uniroot(bval, c(0, 1), cf = cf)$root 12 | } 13 | 14 | # ytm() - доходность к погашению 15 | ytm(cf) 16 | ## [1] 0.05999552 17 | -------------------------------------------------------------------------------- /R_BASIC/yieldBonds.R: -------------------------------------------------------------------------------- 1 | # Create cash flow vector 2 | cf <- c(-95.79, 5, 5, 5, 5, 105) 3 | 4 | # Create bond valuation function 5 | bval <- function(i, cf, 6 | t=seq(along = cf)) 7 | sum(cf / (1 + i)^t) 8 | 9 | # Create ytm() function using uniroot 10 | ytm <- function(cf) { 11 | uniroot(bval, c(0, 1), cf = cf)$root 12 | } 13 | 14 | # Use ytm() function to find yield 15 | ytm(cf) 16 | ## [1] 0.05999552 17 | -------------------------------------------------------------------------------- /UNIX_NETWORK/Chapter_PTHREAD/makefile: -------------------------------------------------------------------------------- 1 | src = $(wildcard *.c) 2 | targets = $(patsubst %.c, %, $(src)) 3 | 4 | CC = gcc 5 | CFLAGS = -lpthread -Wall -g 6 | 7 | all:$(targets) 8 | 9 | $(targets):%:%.c 10 | $(CC) $< -o $@ $(CFLAGS) 11 | 12 | .PHONY:clean all 13 | clean: 14 | -rm -rf $(targets) 15 | 16 | -------------------------------------------------------------------------------- /UNIX_NETWORK/Chapter_SINGLE/wrap.h: -------------------------------------------------------------------------------- 1 | #ifndef _WRAP_H_ 2 | #define _WRAP_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | void sys_err(const char *str); 11 | int Socket(int domain, int type, int protocol); 12 | int Listen(int sockfd, int backlog); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /UNIX_NETWORK/Chapter_UDP/makefile: -------------------------------------------------------------------------------- 1 | src = $(wildcard *.c) 2 | targets = $(patsubst %.c, %, $(src)) 3 | 4 | CC = gcc 5 | CFLAGS = -Wall -g 6 | 7 | all:$(targets) 8 | 9 | $(targets):%:%.c 10 | $(CC) $< -o $@ $(CFLAGS) 11 | 12 | .PHONY:clean all 13 | clean: 14 | -rm -rf $(targets) 15 | 16 | -------------------------------------------------------------------------------- /UNIX_NETWORK/Chapter_WEB/README.md: -------------------------------------------------------------------------------- 1 | # HttpWebServer 2 | Use epoll multi-channel IO transfer method to realize file server under http protocol 3 | -------------------------------------------------------------------------------- /UNIX_NETWORK/Chapter_WEB/makefile: -------------------------------------------------------------------------------- 1 | src = $(wildcard ./src/*.cpp) 2 | obj = $(patsubst ./src/%.cpp, ./obj/%.o, $(src)) 3 | 4 | inc_path = ./inc 5 | myArgs= -Wall -g 6 | target=server 7 | CC=g++ 8 | 9 | ALL:$(target) 10 | 11 | $(target):$(obj) 12 | $(CC) $^ -o $@ $(myArgs) 13 | 14 | $(obj):./obj/%.o:./src/%.cpp 15 | $(CC) -c $^ -o $@ $(myArgs) -I $(inc_path) 16 | 17 | clean: 18 | -rm -rf $(obj) $(target) 19 | 20 | .PHONY: clean ALL 21 | 22 | -------------------------------------------------------------------------------- /UNIX_NETWORK/Chapter_WEB/src/main.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:main.cpp 3 | * Author: KCN_yu 4 | * Createtime:Sat 19 Jun 2021 02:57:51 PM CST 5 | ================================================================*/ 6 | 7 | #include "web_server.h" 8 | 9 | int main() 10 | { 11 | chdir("/root/Program"); 12 | WebServer serv(9999); 13 | serv.RunServer(); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_DYNAMIC/inc/mymath.h: -------------------------------------------------------------------------------- 1 | #ifndef _MYMATH_H 2 | #define _MYMATH_H 3 | 4 | int add(int,int); 5 | int sub(int,int); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_DYNAMIC/lib/libmymath.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/UNIX_SYSTEM/Chapter_DYNAMIC/lib/libmymath.so -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_DYNAMIC/note.txt: -------------------------------------------------------------------------------- 1 | g++ -c add.cpp sub.cpp -fPIC 2 | # add.o sub.o 3 | # -fPIC generate location-independent code 4 | 5 | g++ -shared -o libmymath.so add.o sub.o 6 | # generate dynamic library 7 | 8 | g++ test.cpp -L ./lib -l mymath -I ./inc -o test 9 | # -L decide the path library 10 | # -l decide the name library 11 | # -I include headfile 12 | 13 | export LD_LIBRARY_PATH=./lib 14 | # no blank space 15 | 16 | ============================== 17 | -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_DYNAMIC/src/add.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:add.cpp 3 | * Author: KCN_yu 4 | * Createtime:Thu 20 May 2021 01:44:25 AM CST 5 | ================================================================*/ 6 | 7 | int add(int a, int b) 8 | { 9 | return a+b; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_DYNAMIC/src/add.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/UNIX_SYSTEM/Chapter_DYNAMIC/src/add.o -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_DYNAMIC/src/sub.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:sub.cpp 3 | * Author: KCN_yu 4 | * Createtime:Thu 20 May 2021 01:44:59 AM CST 5 | ================================================================*/ 6 | 7 | int sub(int a, int b) 8 | { 9 | return a-b; 10 | } 11 | -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_DYNAMIC/src/sub.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/UNIX_SYSTEM/Chapter_DYNAMIC/src/sub.o -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_DYNAMIC/test.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:test.cpp 3 | * Author: KCN_yu 4 | * Createtime:Thu 20 May 2021 01:46:22 AM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include "mymath.h" 9 | using namespace std; 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | cout << add(1,2) << endl; 14 | cout << sub(1,2) << endl; 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_STATIC/inc/mymath.h: -------------------------------------------------------------------------------- 1 | #ifndef _MYMATH_H 2 | #define _MYMATH_H 3 | 4 | int add(int,int); 5 | int sub(int,int); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_STATIC/lib/libmymath.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/UNIX_SYSTEM/Chapter_STATIC/lib/libmymath.a -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_STATIC/note.txt: -------------------------------------------------------------------------------- 1 | g++ add.c sub.c -c 2 | # add.o sub.o 3 | 4 | ar csr libmymath.a add.o sub.o 5 | # get static library 6 | # c - create 7 | # s - make a index ??? 8 | # r - replace ??? 9 | 10 | g++ test.cpp ./lib/libmymath.a -I ./inc -o test 11 | # link the static library 12 | # lib --library 13 | # inc --include headfile 14 | 15 | ============================== 16 | 17 | In language has implicit declaration, which means int add(int,int); 18 | but in cpp doesn't have, so we need the mymath.h(only declaration), and have to include "mymath" 19 | -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_STATIC/src/add.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:add.cpp 3 | * Author: KCN_yu 4 | * Createtime:Thu 20 May 2021 01:44:25 AM CST 5 | ================================================================*/ 6 | 7 | int add(int a, int b) 8 | { 9 | return a+b; 10 | } 11 | 12 | -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_STATIC/src/add.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/UNIX_SYSTEM/Chapter_STATIC/src/add.o -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_STATIC/src/sub.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:sub.cpp 3 | * Author: KCN_yu 4 | * Createtime:Thu 20 May 2021 01:44:59 AM CST 5 | ================================================================*/ 6 | 7 | int sub(int a, int b) 8 | { 9 | return a-b; 10 | } 11 | -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_STATIC/src/sub.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/UNIX_SYSTEM/Chapter_STATIC/src/sub.o -------------------------------------------------------------------------------- /UNIX_SYSTEM/Chapter_STATIC/test.cpp: -------------------------------------------------------------------------------- 1 | /*================================================================ 2 | * Filename:test.cpp 3 | * Author: KCN_yu 4 | * Createtime:Thu 20 May 2021 01:46:22 AM CST 5 | ================================================================*/ 6 | 7 | #include 8 | #include "mymath.h" 9 | using namespace std; 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | vector v; 14 | cout << add(1,2) << endl; 15 | cout << sub(1,2) << endl; 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /WHY_THEORY/CLASS/Makefile: -------------------------------------------------------------------------------- 1 | CFLAGS := -O2 -Wall -Wextra 2 | OBJS := task_6_2.o queue.o 3 | all: $(OBJS) 4 | gcc $(CFLAGS) $(OBJS) -o task_6_2 5 | .PHONY: all -------------------------------------------------------------------------------- /WHY_THEORY/CLASS/main.why: -------------------------------------------------------------------------------- 1 | theory Main 2 | 3 | use import int.Int 4 | 5 | (* goal test: forall x. x > 0 -> not(forall t. t > 0 -> x * t = x) 6 | goal G: forall x. x > 0 -> (exists t. t > 0 /\ x*t <> x) *) 7 | lemma L: forall x. x * 2 = x + x 8 | (* goal G: forall x. x * 2 = x + x /\ x > 0 -> not(forall t. t > 0 -> x * t = x) *) 9 | goal G: forall x. x > 0 -> not(forall t. t > 0 -> x * t = x) 10 | 11 | goal G2: forall x,y,z:int. (x < y < z) -> 12 | 13 | end 14 | -------------------------------------------------------------------------------- /WHY_THEORY/CLASS/task_3_2.mlw: -------------------------------------------------------------------------------- 1 | module Task32 2 | 3 | use import int.Int 4 | 5 | let rec ghost sqrt_g (x : int) : int 6 | requires {x >= 0} 7 | variant {x} 8 | ensures {result * result <= x < (result + 1) * (result + 1)} 9 | = 10 | if x = 0 then 0 11 | else let r = sqrt_g (x - 1) in 12 | if (r + 1) * (r + 1) = x then r + 1 13 | else r 14 | 15 | let sqrt_gr_zero (x : int) 16 | requires {x >= 0} 17 | = 18 | let ghost r2d2 = sqrt_g x in 19 | assert {exists r : int. r * r <= x < (r + 1) * (r + 1)} 20 | end -------------------------------------------------------------------------------- /WHY_THEORY/TASK1/task1.1/task1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/WHY_THEORY/TASK1/task1.1/task1.pdf -------------------------------------------------------------------------------- /WHY_THEORY/TASK1/task1.1/task1/why3shapes.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/WHY_THEORY/TASK1/task1.1/task1/why3shapes.gz -------------------------------------------------------------------------------- /WHY_THEORY/TASK1/task1.1/task2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/WHY_THEORY/TASK1/task1.1/task2.pdf -------------------------------------------------------------------------------- /WHY_THEORY/TASK1/task1.1/task2/why3shapes.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/WHY_THEORY/TASK1/task1.1/task2/why3shapes.gz -------------------------------------------------------------------------------- /WHY_THEORY/TASK1/task1.1/task2/why3shapes.gz.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/WHY_THEORY/TASK1/task1.1/task2/why3shapes.gz.bak -------------------------------------------------------------------------------- /WHY_THEORY/TASK1/task1.2/task.c: -------------------------------------------------------------------------------- 1 | int P(int x) 2 | { 3 | int y1 = 0, y2 = 0, y3 = 1; 4 | y2 = y2 + y3; 5 | while (y2 <= x) 6 | { 7 | y1 = y1 + 1; 8 | y3 = y3 + 6 * y1; 9 | 10 | y2 = y2 + y3; 11 | } 12 | int z = y1; 13 | return z; 14 | } -------------------------------------------------------------------------------- /WHY_THEORY/TASK1/task1.2/task.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/WHY_THEORY/TASK1/task1.2/task.pdf -------------------------------------------------------------------------------- /WHY_THEORY/TASK1/task1.2/task/why3shapes.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/WHY_THEORY/TASK1/task1.2/task/why3shapes.gz -------------------------------------------------------------------------------- /WHY_THEORY/TASK1/task1.3/task.c: -------------------------------------------------------------------------------- 1 | int P(int x) 2 | { 3 | int y1 = x, y2 = 1, y3 = x; 4 | 5 | do 6 | { 7 | while (y2 < y3) 8 | { 9 | y1 = y1 + x; 10 | y2 = y2 + 1; 11 | } 12 | if (y3 != x) 13 | { 14 | break; 15 | } 16 | else 17 | { 18 | y3 = y1; 19 | continue; 20 | } 21 | } while (1); 22 | 23 | int z = y1; 24 | return z; 25 | } -------------------------------------------------------------------------------- /WHY_THEORY/TASK1/task1.3/task.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/WHY_THEORY/TASK1/task1.3/task.pdf -------------------------------------------------------------------------------- /WHY_THEORY/TASK1/task1.3/task/why3shapes.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/WHY_THEORY/TASK1/task1.3/task/why3shapes.gz -------------------------------------------------------------------------------- /WHY_THEORY/TASK2/task2.1/task/why3shapes.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/WHY_THEORY/TASK2/task2.1/task/why3shapes.gz -------------------------------------------------------------------------------- /WHY_THEORY/TASK2/task2.2/task/why3shapes.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KCNyu/Program-MSU/d20eeee133befcb28d545ecd770c2af735e2b016/WHY_THEORY/TASK2/task2.2/task/why3shapes.gz -------------------------------------------------------------------------------- /WHY_THEORY/TASK4/map.h: -------------------------------------------------------------------------------- 1 | #ifndef __MAP_H__ 2 | #define __MAP_H__ 3 | 4 | #include "maptypes.h" 5 | 6 | int initializeMap(Map *map, int size); 7 | 8 | void finalizeMap(Map *map); 9 | 10 | int addElement(Map *map, Key *key, Value *value); 11 | 12 | int removeElement(Map *map, Key *key, Value *value); 13 | 14 | int getElement(Map *map, Key *key, Value *value); 15 | 16 | #endif // __MAP_H__ 17 | -------------------------------------------------------------------------------- /WHY_THEORY/TASK4/maptypes.h: -------------------------------------------------------------------------------- 1 | #ifndef __MAPTYPES_H__ 2 | #define __MAPTYPES_H__ 3 | 4 | typedef struct { 5 | int a; 6 | int b; 7 | } Key; 8 | 9 | typedef struct { 10 | int c; 11 | int d; 12 | } Value; 13 | 14 | typedef struct { 15 | Key key __attribute__((noembed)); 16 | Value value; 17 | int existent; 18 | } Item; 19 | 20 | typedef struct { 21 | Item *items; 22 | int capacity; 23 | int count; 24 | } Map; 25 | 26 | #endif // __MAPTYPES_H__ 27 | --------------------------------------------------------------------------------