Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zhhf96
C-Plus-Plus-TheAlgorithms
提交
ac1ba3a6
C
C-Plus-Plus-TheAlgorithms
项目概览
zhhf96
/
C-Plus-Plus-TheAlgorithms
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
C-Plus-Plus-TheAlgorithms
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
ac1ba3a6
编写于
11月 28, 2019
作者:
C
Christian Clauss
提交者:
GitHub
11月 28, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename Others -> others (#648)
* rename Others -> temp * rename Others -> others
上级
6fe40bd0
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
141 addition
and
141 deletion
+141
-141
others/Buzz_number.cpp
others/Buzz_number.cpp
+0
-0
others/Decimal To Binary.cpp
others/Decimal To Binary.cpp
+0
-0
others/Decimal To Hexadecimal .cpp
others/Decimal To Hexadecimal .cpp
+0
-0
others/Decimal to Roman Numeral.cpp
others/Decimal to Roman Numeral.cpp
+0
-0
others/GCD_of_n_numbers.cpp
others/GCD_of_n_numbers.cpp
+0
-0
others/Palindromeofnumber.cpp
others/Palindromeofnumber.cpp
+0
-0
others/Paranthesis Matching.cpp
others/Paranthesis Matching.cpp
+0
-0
others/Primality Test.cpp
others/Primality Test.cpp
+0
-0
others/Sparse matrix.cpp
others/Sparse matrix.cpp
+0
-0
others/Strassen Matrix Multiplication.cpp
others/Strassen Matrix Multiplication.cpp
+0
-0
others/String Fibonacci.cpp
others/String Fibonacci.cpp
+0
-0
others/Tower of Hanoi.cpp
others/Tower of Hanoi.cpp
+0
-0
others/fibonacci.cpp
others/fibonacci.cpp
+0
-0
others/happy_number.cpp
others/happy_number.cpp
+0
-0
others/pascal_triangle.cpp
others/pascal_triangle.cpp
+63
-63
others/sieve_of_Eratosthenes.cpp
others/sieve_of_Eratosthenes.cpp
+0
-0
others/smallest-circle.cpp
others/smallest-circle.cpp
+0
-0
others/spiral_print.cpp
others/spiral_print.cpp
+78
-78
others/vector_important_functions.cpp
others/vector_important_functions.cpp
+0
-0
未找到文件。
O
thers/Buzz_number.cpp
→
o
thers/Buzz_number.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/Decimal To Binary.cpp
→
o
thers/Decimal To Binary.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/Decimal To Hexadecimal .cpp
→
o
thers/Decimal To Hexadecimal .cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/Decimal to Roman Numeral.cpp
→
o
thers/Decimal to Roman Numeral.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/GCD_of_n_numbers.cpp
→
o
thers/GCD_of_n_numbers.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/Palindromeofnumber.cpp
→
o
thers/Palindromeofnumber.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/Paranthesis Matching.cpp
→
o
thers/Paranthesis Matching.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/Primality Test.cpp
→
o
thers/Primality Test.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/Sparse matrix.cpp
→
o
thers/Sparse matrix.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/Strassen Matrix Multiplication.cpp
→
o
thers/Strassen Matrix Multiplication.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/String Fibonacci.cpp
→
o
thers/String Fibonacci.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/Tower of Hanoi.cpp
→
o
thers/Tower of Hanoi.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/fibonacci.cpp
→
o
thers/fibonacci.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/happy_number.cpp
→
o
thers/happy_number.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/pascal_triangle.cpp
→
o
thers/pascal_triangle.cpp
浏览文件 @
ac1ba3a6
#include<iostream>
using
namespace
std
;
void
show_pascal
(
int
**
arr
,
int
n
)
{
//pint Pascal's Triangle
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
for
(
int
j
=
0
;
j
<
n
+
i
;
++
j
)
{
if
(
arr
[
i
][
j
]
==
0
)
cout
<<
" "
;
else
cout
<<
arr
[
i
][
j
];
}
cout
<<
endl
;
}
}
int
**
pascal_triangle
(
int
**
arr
,
int
n
)
{
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
for
(
int
j
=
n
-
i
-
1
;
j
<
n
+
i
;
++
j
)
{
if
(
j
==
n
-
i
-
1
||
j
==
n
+
i
-
1
)
arr
[
i
][
j
]
=
1
;
//The edge of the Pascal triangle goes in 1
else
arr
[
i
][
j
]
=
arr
[
i
-
1
][
j
-
1
]
+
arr
[
i
-
1
][
j
+
1
];
}
}
return
arr
;
}
int
main
()
{
int
n
=
0
;
cout
<<
"Set Pascal's Triangle Height"
<<
endl
;
cin
>>
n
;
//memory allocation (Assign two-dimensional array to store Pascal triangle)
int
**
arr
=
new
int
*
[
n
];
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
arr
[
i
]
=
new
int
[
2
*
n
-
1
];
memset
(
arr
[
i
],
0
,
sizeof
(
int
)
*
(
2
*
n
-
1
));
}
pascal_triangle
(
arr
,
n
);
show_pascal
(
arr
,
n
);
//deallocation
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
delete
[]
arr
[
i
];
}
delete
[]
arr
;
return
0
;
}
#include<iostream>
using
namespace
std
;
void
show_pascal
(
int
**
arr
,
int
n
)
{
//pint Pascal's Triangle
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
for
(
int
j
=
0
;
j
<
n
+
i
;
++
j
)
{
if
(
arr
[
i
][
j
]
==
0
)
cout
<<
" "
;
else
cout
<<
arr
[
i
][
j
];
}
cout
<<
endl
;
}
}
int
**
pascal_triangle
(
int
**
arr
,
int
n
)
{
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
for
(
int
j
=
n
-
i
-
1
;
j
<
n
+
i
;
++
j
)
{
if
(
j
==
n
-
i
-
1
||
j
==
n
+
i
-
1
)
arr
[
i
][
j
]
=
1
;
//The edge of the Pascal triangle goes in 1
else
arr
[
i
][
j
]
=
arr
[
i
-
1
][
j
-
1
]
+
arr
[
i
-
1
][
j
+
1
];
}
}
return
arr
;
}
int
main
()
{
int
n
=
0
;
cout
<<
"Set Pascal's Triangle Height"
<<
endl
;
cin
>>
n
;
//memory allocation (Assign two-dimensional array to store Pascal triangle)
int
**
arr
=
new
int
*
[
n
];
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
arr
[
i
]
=
new
int
[
2
*
n
-
1
];
memset
(
arr
[
i
],
0
,
sizeof
(
int
)
*
(
2
*
n
-
1
));
}
pascal_triangle
(
arr
,
n
);
show_pascal
(
arr
,
n
);
//deallocation
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
delete
[]
arr
[
i
];
}
delete
[]
arr
;
return
0
;
}
O
thers/sieve_of_Eratosthenes.cpp
→
o
thers/sieve_of_Eratosthenes.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/smallest-circle.cpp
→
o
thers/smallest-circle.cpp
浏览文件 @
ac1ba3a6
文件已移动
O
thers/spiral_print.cpp
→
o
thers/spiral_print.cpp
浏览文件 @
ac1ba3a6
#include <iostream>
using
namespace
std
;
void
genArray
(
int
a
[][
10
],
int
r
,
int
c
)
{
int
value
=
1
;
for
(
int
i
=
0
;
i
<
r
;
i
++
)
{
for
(
int
j
=
0
;
j
<
c
;
j
++
)
{
a
[
i
][
j
]
=
value
;
cout
<<
a
[
i
][
j
]
<<
" "
;
value
++
;
}
cout
<<
endl
;
}
}
void
spiralPrint
(
int
a
[][
10
],
int
r
,
int
c
)
{
int
startRow
=
0
,
endRow
=
r
-
1
;
int
startCol
=
0
,
endCol
=
c
-
1
;
int
cnt
=
0
;
while
(
startRow
<=
endRow
&&
startCol
<=
endCol
)
{
///Print start row
for
(
int
i
=
startCol
;
i
<=
endCol
;
i
++
,
cnt
++
)
{
cout
<<
a
[
startRow
][
i
]
<<
" "
;
}
startRow
++
;
///Print the end col
for
(
int
i
=
startRow
;
i
<=
endRow
;
i
++
,
cnt
++
)
{
cout
<<
a
[
i
][
endCol
]
<<
" "
;
}
endCol
--
;
///Print the end row
if
(
cnt
==
r
*
c
)
{
break
;
}
for
(
int
i
=
endCol
;
i
>=
startCol
;
i
--
,
cnt
++
)
{
cout
<<
a
[
endRow
][
i
]
<<
" "
;
}
endRow
--
;
///Print the start Col
if
(
cnt
==
r
*
c
)
{
break
;
}
for
(
int
i
=
endRow
;
i
>=
startRow
;
i
--
,
cnt
++
)
{
cout
<<
a
[
i
][
startCol
]
<<
" "
;
}
startCol
++
;
}
}
int
main
()
{
int
a
[
10
][
10
];
int
r
,
c
;
cin
>>
r
>>
c
;
genArray
(
a
,
r
,
c
);
spiralPrint
(
a
,
r
,
c
);
return
0
;
}
#include <iostream>
using
namespace
std
;
void
genArray
(
int
a
[][
10
],
int
r
,
int
c
)
{
int
value
=
1
;
for
(
int
i
=
0
;
i
<
r
;
i
++
)
{
for
(
int
j
=
0
;
j
<
c
;
j
++
)
{
a
[
i
][
j
]
=
value
;
cout
<<
a
[
i
][
j
]
<<
" "
;
value
++
;
}
cout
<<
endl
;
}
}
void
spiralPrint
(
int
a
[][
10
],
int
r
,
int
c
)
{
int
startRow
=
0
,
endRow
=
r
-
1
;
int
startCol
=
0
,
endCol
=
c
-
1
;
int
cnt
=
0
;
while
(
startRow
<=
endRow
&&
startCol
<=
endCol
)
{
///Print start row
for
(
int
i
=
startCol
;
i
<=
endCol
;
i
++
,
cnt
++
)
{
cout
<<
a
[
startRow
][
i
]
<<
" "
;
}
startRow
++
;
///Print the end col
for
(
int
i
=
startRow
;
i
<=
endRow
;
i
++
,
cnt
++
)
{
cout
<<
a
[
i
][
endCol
]
<<
" "
;
}
endCol
--
;
///Print the end row
if
(
cnt
==
r
*
c
)
{
break
;
}
for
(
int
i
=
endCol
;
i
>=
startCol
;
i
--
,
cnt
++
)
{
cout
<<
a
[
endRow
][
i
]
<<
" "
;
}
endRow
--
;
///Print the start Col
if
(
cnt
==
r
*
c
)
{
break
;
}
for
(
int
i
=
endRow
;
i
>=
startRow
;
i
--
,
cnt
++
)
{
cout
<<
a
[
i
][
startCol
]
<<
" "
;
}
startCol
++
;
}
}
int
main
()
{
int
a
[
10
][
10
];
int
r
,
c
;
cin
>>
r
>>
c
;
genArray
(
a
,
r
,
c
);
spiralPrint
(
a
,
r
,
c
);
return
0
;
}
O
thers/vector_important_functions.cpp
→
o
thers/vector_important_functions.cpp
浏览文件 @
ac1ba3a6
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录