Skip to content

Commit 8941d9c

Browse files
committed
0.0.001
1 ,add cpp files to respository
1 parent 778ec38 commit 8941d9c

File tree

121 files changed

+6299
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+6299
-0
lines changed

.vscode/launch.json

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "(gdb) 启动",
5+
"type": "cppdbg",
6+
"request": "launch",
7+
"program": "${workspaceFolder}/Variable_Number_of_rguments_in_C.exe",
8+
"args": [],
9+
"stopAtEntry": false,
10+
"cwd": "${fileDirname}",
11+
"environment": [],
12+
"externalConsole": true,
13+
"MIMode": "gdb",
14+
"miDebuggerPath": "D:\\mingw810\\bin\\gdb.exe",
15+
"setupCommands": [
16+
{
17+
"description": "为 gdb 启用整齐打印",
18+
"text": "-enable-pretty-printing",
19+
"ignoreFailures": true
20+
},
21+
{
22+
"description": "将反汇编风格设置为 Intel",
23+
"text": "-gdb-set disassembly-flavor intel",
24+
"ignoreFailures": true
25+
}
26+
]
27+
},
28+
{
29+
"name": "C/C++: gcc.exe 生成和调试活动文件",
30+
"type": "cppdbg",
31+
"request": "launch",
32+
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
33+
"args": [],
34+
"stopAtEntry": false,
35+
"cwd": "${fileDirname}",
36+
"environment": [],
37+
"externalConsole": false,
38+
"MIMode": "gdb",
39+
"miDebuggerPath": "D:\\mingw810\\bin\\gdb.exe",
40+
"setupCommands": [
41+
{
42+
"description": "为 gdb 启用整齐打印",
43+
"text": "-enable-pretty-printing",
44+
"ignoreFailures": true
45+
},
46+
{
47+
"description": "将反汇编风格设置为 Intel",
48+
"text": "-gdb-set disassembly-flavor intel",
49+
"ignoreFailures": true
50+
}
51+
],
52+
"preLaunchTask": "C/C++: gcc.exe 生成活动文件"
53+
}
54+
],
55+
"version": "2.0.0"
56+
}

.vscode/settings.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"files.associations": {
3+
"codwars_lv5.h": "c",
4+
"typeinfo": "c",
5+
"cmath": "cpp",
6+
"cctype": "cpp",
7+
"stdarg.h": "c",
8+
"time.h": "c",
9+
"aes.h": "c",
10+
"array": "cpp",
11+
"atomic": "cpp",
12+
"*.tcc": "cpp",
13+
"clocale": "cpp",
14+
"cstdarg": "cpp",
15+
"cstddef": "cpp",
16+
"cstdint": "cpp",
17+
"cstdio": "cpp",
18+
"cstdlib": "cpp",
19+
"cwchar": "cpp",
20+
"cwctype": "cpp",
21+
"deque": "cpp",
22+
"unordered_map": "cpp",
23+
"vector": "cpp",
24+
"exception": "cpp",
25+
"algorithm": "cpp",
26+
"memory": "cpp",
27+
"memory_resource": "cpp",
28+
"optional": "cpp",
29+
"string": "cpp",
30+
"string_view": "cpp",
31+
"system_error": "cpp",
32+
"tuple": "cpp",
33+
"type_traits": "cpp",
34+
"utility": "cpp",
35+
"fstream": "cpp",
36+
"initializer_list": "cpp",
37+
"iosfwd": "cpp",
38+
"iostream": "cpp",
39+
"istream": "cpp",
40+
"limits": "cpp",
41+
"new": "cpp",
42+
"ostream": "cpp",
43+
"sstream": "cpp",
44+
"stdexcept": "cpp",
45+
"streambuf": "cpp",
46+
"cinttypes": "cpp",
47+
"map": "cpp",
48+
"set": "cpp"
49+
},
50+
"C_Cpp.errorSquiggles": "disabled"
51+
}

.vscode/tasks.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"tasks": [
3+
{
4+
"type": "cppbuild",
5+
"label": "C/C++: gcc.exe 生成活动文件",
6+
"command": "D:\\mingw810\\bin\\gcc.exe",
7+
"args": [
8+
"-fdiagnostics-color=always",
9+
"-g",
10+
"${file}",
11+
"-o",
12+
"${fileDirname}\\${fileBasenameNoExtension}.exe"
13+
],
14+
"options": {
15+
"cwd": "${fileDirname}"
16+
},
17+
"problemMatcher": [
18+
"$gcc"
19+
],
20+
"group": {
21+
"kind": "build",
22+
"isDefault": true
23+
},
24+
"detail": "调试器生成的任务。"
25+
}
26+
],
27+
"version": "2.0.0"
28+
}

Bouncingball.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include<iostream>
2+
3+
class Bouncingball
4+
{
5+
public:
6+
static int bouncingBall(double h, double bounce, double window);
7+
};
8+
9+
10+
int Bouncingball::bouncingBall(double h, double bounce,double window)
11+
{
12+
int cnt =0;
13+
14+
if((h > 0 ) && ( bounce >0)&&( bounce <1)&&( window <h)&&(window >0))
15+
{
16+
for(h*=bounce; h > window; h*=bounce,cnt++);
17+
return (cnt*2+1);
18+
}
19+
return -1;
20+
}
21+
22+
23+
24+
int main()
25+
{
26+
using namespace std;
27+
28+
29+
Bouncingball bb;
30+
31+
cout<<"hello wold"<<endl;
32+
33+
cout<<bb.bouncingBall(3,0.66,1.5)<<endl;
34+
35+
return 0;
36+
}

Buddy_Pairs.c

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include<stdio.h>
2+
#include<math.h>
3+
#include<time.h>
4+
5+
6+
int main()
7+
{
8+
9+
10+
11+
return 0;
12+
}

CMakeLists.txt

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
cmake_minimum_required(VERSION 3.2)
2+
project(test_aes128_ecb CXX C)
3+
set(C_STANDARD 18)
4+
set(C_STANDARD_REQUIRED true)
5+
6+
7+
# add_executable(test_aes128_ecb main.cpp aes.c cgms_crc.c codewars_lv5.c)
8+
# add_executable(MultiplyingNumberAsStrings MultiplyingNumberAsStrings.cpp)
9+
# add_executable(TheObservedPIN TheObservedPIN.cpp)
10+
# add_executable(FindTheDivisors FindTheDivisors.cpp)
11+
# add_executable(is_valid_ISBN_10 is_valid_ISBN_10.cpp)
12+
# add_executable(scramble scramble.cpp)
13+
# add_executable(human_readable_time human_readable_time.cpp)
14+
# add_executable(mean_square_error mean_square_error.cpp)
15+
# add_executable(uint32_to_ip uint32_to_ip.cpp)
16+
# add_executable(hex_str_to_rgb hex_str_to_rgb.cpp)
17+
# add_executable(chooseBestSum chooseBestSum.c)
18+
# add_executable(args_LCM args_LCM.c)
19+
# add_executable(GCD GCD.c)
20+
# add_executable(matrix_multiplication matrix_multiplication.c)
21+
# add_executable(work_on_strings work_on_strings.c)
22+
# add_executable(Buddy_Pairs Buddy_Pairs.c)
23+
# add_executable(string_add string_add.c)
24+
25+
# add_executable(find_reverse_number find_reverse_number.c)
26+
# add_executable(get_TCP_state get_TCP_state.c)
27+
# add_executable(sum_intervals sum_intervals.c)
28+
# add_executable(Split_Strings Split_Strings.cpp)
29+
# add_executable(Bouncingball Bouncingball.cpp)
30+
# add_executable(TwoToOne TwoToOne.cpp)
31+
# add_executable(get_middle get_middle.cpp)
32+
# add_executable(find_even_index find_even_index.cpp)
33+
34+
35+
# add_executable(count count.cpp)
36+
# add_executable(maxSequence maxSequence.cpp)
37+
# add_executable(SumFct SumFct.cpp)
38+
# add_executable(rot13 rot13.cpp)
39+
# add_executable(move_zeroes move_zeroes.cpp)
40+
# add_executable(highestScoringWord highestScoringWord.cpp)
41+
# add_executable(properFractions properFractions.c)
42+
# add_executable(is_merge is_merge.c)
43+
# add_executable(test_negtive test_negtive.c)
44+
# add_executable(beeramid beeramid.c)
45+
# add_executable(search_substr search_substr.c)
46+
# add_executable(score_hand score_hand.c)
47+
# add_executable(power_sum_dig_term power_sum_dig_term.c)
48+
# add_executable(closest closest.c)
49+
# add_executable(base64_to_base10 base64_to_base10.c)
50+
51+
# add_executable(next_smaller_number next_smaller_number.c)
52+
# add_executable(Greed_is_Good Greed_is_Good.c)
53+
# add_executable(strsum strsum.c)
54+
# add_executable(countones countones.c)
55+
# add_executable(countones Find_the_missing_letter.cpp)
56+
# add_executable(Product_of_consecutive_Fib_numbers Product_of_consecutive_Fib_numbers.c)
57+
add_executable(Variable_Number_of_rguments_in_C Variable_Number_of_rguments_in_C.c)
58+
59+
60+
61+
62+
63+
64+
65+
66+
67+
68+
69+
70+

FindTheDivisors.cpp

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include<stdio.h>
2+
#include<stdlib.h>
3+
4+
5+
// assign divisors to array[]
6+
// set *length to the number of divisors
7+
8+
void divisors(unsigned n, size_t *length, unsigned array[]) {
9+
10+
// <---- hajime!
11+
12+
size_t y =0;
13+
14+
*length =0;
15+
16+
// array = (unsigned *)( malloc(sizeof(unsigned) * n));
17+
18+
for( unsigned x =2; x< n; x++)
19+
{
20+
if( n%x == 0 )
21+
{
22+
printf("x = %d", x);
23+
(*length )++ ;
24+
array[y++]= x;
25+
}
26+
27+
}
28+
29+
}
30+
31+
32+
int main()
33+
{
34+
35+
size_t length =0;
36+
unsigned array[50];
37+
38+
divisors(15,&length,array);
39+
40+
printf("length =%d\r\n",length);
41+
42+
for(size_t x =0; x <length; x++)
43+
{
44+
printf("array[%d] = %d\r\n", x,array[x]);
45+
}
46+
47+
return 0;
48+
}

Find_the_missing_letter.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include<vector>
2+
#include<iostream>
3+
4+
5+
char findMissingLetter(const std::vector<char>& chars)
6+
{
7+
// TODO: Find the missing char in the consecutive letter sequence and return it.
8+
char c_start = chars[0];
9+
10+
for(size_t x=1; x<chars.size(); c_start = chars[x],x++)
11+
{
12+
if((chars[x]-c_start) > 1)
13+
return c_start+1;
14+
}
15+
return ' ';
16+
}
17+
18+
19+
int main(void)
20+
{
21+
22+
// std::vector<char> chars={'a', 'b', 'c', 'd', 'f'};
23+
24+
std::vector<char> chars={'O', 'Q', 'R', 'S'};
25+
26+
std::cout<< findMissingLetter(chars) <<std::endl;
27+
28+
return 0;
29+
}

0 commit comments

Comments
 (0)