Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Administrator
Public Cpp Test
Commits
2a291a73
Commit
2a291a73
authored
Oct 23, 2023
by
shengnan hu
Browse files
main
parents
Changes
638
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
360 additions
and
0 deletions
+360
-0
BM-GJB8114-2013/A-1-1-2/A-1-1-2-bad.c
BM-GJB8114-2013/A-1-1-2/A-1-1-2-bad.c
+12
-0
BM-GJB8114-2013/A-1-1-2/A-1-1-2-bad.cpp
BM-GJB8114-2013/A-1-1-2/A-1-1-2-bad.cpp
+12
-0
BM-GJB8114-2013/A-1-1-2/A-1-1-2-good.c
BM-GJB8114-2013/A-1-1-2/A-1-1-2-good.c
+13
-0
BM-GJB8114-2013/A-1-1-2/A-1-1-2-good.cpp
BM-GJB8114-2013/A-1-1-2/A-1-1-2-good.cpp
+13
-0
BM-GJB8114-2013/A-1-6-6/A-1-6-6-bad.c
BM-GJB8114-2013/A-1-6-6/A-1-6-6-bad.c
+8
-0
BM-GJB8114-2013/A-1-6-6/A-1-6-6-bad.cpp
BM-GJB8114-2013/A-1-6-6/A-1-6-6-bad.cpp
+8
-0
BM-GJB8114-2013/A-1-7-5/A-1-7-5-bad.c
BM-GJB8114-2013/A-1-7-5/A-1-7-5-bad.c
+29
-0
BM-GJB8114-2013/A-1-7-5/A-1-7-5-bad.cpp
BM-GJB8114-2013/A-1-7-5/A-1-7-5-bad.cpp
+29
-0
BM-GJB8114-2013/A-1-7-5/A-1-7-5-good.c
BM-GJB8114-2013/A-1-7-5/A-1-7-5-good.c
+32
-0
BM-GJB8114-2013/A-1-7-5/A-1-7-5-good.cpp
BM-GJB8114-2013/A-1-7-5/A-1-7-5-good.cpp
+32
-0
BM-GJB8114-2013/A-2-7-1/A-2-7-1-bad.cpp
BM-GJB8114-2013/A-2-7-1/A-2-7-1-bad.cpp
+32
-0
BM-GJB8114-2013/A-2-7-1/A-2-7-1-good.cpp
BM-GJB8114-2013/A-2-7-1/A-2-7-1-good.cpp
+33
-0
BM-GJB8114-2013/A-2-8-2/A-2-8-2-bad.cpp
BM-GJB8114-2013/A-2-8-2/A-2-8-2-bad.cpp
+30
-0
BM-GJB8114-2013/A-2-9-2/A-2-9-2-bad.cpp
BM-GJB8114-2013/A-2-9-2/A-2-9-2-bad.cpp
+17
-0
BM-GJB8114-2013/A-2-9-4/A-2-9-4-bad.cpp
BM-GJB8114-2013/A-2-9-4/A-2-9-4-bad.cpp
+10
-0
BM-GJB8114-2013/A-2-9-4/A-2-9-4-good.cpp
BM-GJB8114-2013/A-2-9-4/A-2-9-4-good.cpp
+10
-0
BM-GJB8114-2013/R-1-1-1/R-1-1-1-bad.c
BM-GJB8114-2013/R-1-1-1/R-1-1-1-bad.c
+10
-0
BM-GJB8114-2013/R-1-1-1/R-1-1-1-bad.cpp
BM-GJB8114-2013/R-1-1-1/R-1-1-1-bad.cpp
+10
-0
BM-GJB8114-2013/R-1-1-1/R-1-1-1-good.c
BM-GJB8114-2013/R-1-1-1/R-1-1-1-good.c
+10
-0
BM-GJB8114-2013/R-1-1-1/R-1-1-1-good.cpp
BM-GJB8114-2013/R-1-1-1/R-1-1-1-good.cpp
+10
-0
No files found.
BM-GJB8114-2013/A-1-1-2/A-1-1-2-bad.c
0 → 100644
View file @
2a291a73
#define IF0( x ) if ( 0 == ( x ) ) { //提示1
int
main
(
void
)
{
int
test
=
0
;
IF0
(
test
)
test
=
test
+
1
;
}
return
(
0
);
}
BM-GJB8114-2013/A-1-1-2/A-1-1-2-bad.cpp
0 → 100644
View file @
2a291a73
#define IF0( x ) if ( 0 == ( x ) ) { //提示1
int
main
(
void
)
{
int
test
=
0
;
IF0
(
test
)
test
=
test
+
1
;
}
return
(
0
);
}
BM-GJB8114-2013/A-1-1-2/A-1-1-2-good.c
0 → 100644
View file @
2a291a73
#define IF0( x ) if ( 0 == ( x ) ) //遵循1
int
main
(
void
)
{
int
test
=
0
;
IF0
(
test
)
{
test
=
test
+
1
;
}
return
(
0
);
}
BM-GJB8114-2013/A-1-1-2/A-1-1-2-good.cpp
0 → 100644
View file @
2a291a73
#define IF0( x ) if ( 0 == ( x ) ) //遵循1
int
main
(
void
)
{
int
test
=
0
;
IF0
(
test
)
{
test
=
test
+
1
;
}
return
(
0
);
}
BM-GJB8114-2013/A-1-6-6/A-1-6-6-bad.c
0 → 100644
View file @
2a291a73
int
main
(
void
)
{
int
datax
,
datay
,
dataz
;
datax
=
(
datay
=
1
,
dataz
=
2
);
//提示1
return
(
0
);
}
BM-GJB8114-2013/A-1-6-6/A-1-6-6-bad.cpp
0 → 100644
View file @
2a291a73
int
main
(
void
)
{
int
datax
,
datay
,
dataz
;
datax
=
(
datay
=
1
,
dataz
=
2
);
//提示1
return
(
0
);
}
BM-GJB8114-2013/A-1-7-5/A-1-7-5-bad.c
0 → 100644
View file @
2a291a73
void
fun1
(
int
p
[
]
)
//提示1
{
int
i
;
for
(
i
=
0
;
i
<
6
;
i
++
)
{
p
[
i
]
=
p
[
i
]
+
1
;
}
}
void
fun2
(
int
*
p
)
//提示2
{
int
i
;
for
(
i
=
0
;
i
<
6
;
i
++
)
{
p
[
i
]
=
p
[
i
]
+
1
;
}
}
int
main
(
void
)
{
int
a
[
6
]
=
{
0
,
1
,
2
,
3
,
4
,
5
};
fun1
(
a
);
fun2
(
a
);
return
(
0
);
}
BM-GJB8114-2013/A-1-7-5/A-1-7-5-bad.cpp
0 → 100644
View file @
2a291a73
void
fun1
(
int
p
[
]
)
//提示1
{
int
i
;
for
(
i
=
0
;
i
<
6
;
i
++
)
{
p
[
i
]
=
p
[
i
]
+
1
;
}
}
void
fun2
(
int
*
p
)
//提示2
{
int
i
;
for
(
i
=
0
;
i
<
6
;
i
++
)
{
p
[
i
]
=
p
[
i
]
+
1
;
}
}
int
main
(
void
)
{
int
a
[
6
]
=
{
0
,
1
,
2
,
3
,
4
,
5
};
fun1
(
a
);
fun2
(
a
);
return
(
0
);
}
BM-GJB8114-2013/A-1-7-5/A-1-7-5-good.c
0 → 100644
View file @
2a291a73
void
fun1
(
int
p
[
],
int
n
)
//遵循1
{
int
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
p
[
i
]
=
p
[
i
]
+
1
;
}
}
void
fun2
(
int
*
p
,
int
n
)
//遵循2
{
int
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
p
[
i
]
=
p
[
i
]
+
1
;
}
}
int
main
(
void
)
{
int
i
;
int
a
[
6
]
=
{
0
,
1
,
2
,
3
,
4
,
5
};
i
=
sizeof
(
a
)
/
sizeof
(
int
);
fun1
(
a
,
i
);
fun2
(
a
,
i
);
return
(
0
);
}
BM-GJB8114-2013/A-1-7-5/A-1-7-5-good.cpp
0 → 100644
View file @
2a291a73
void
fun1
(
int
p
[
],
int
n
)
//遵循1
{
int
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
p
[
i
]
=
p
[
i
]
+
1
;
}
}
void
fun2
(
int
*
p
,
int
n
)
//遵循2
{
int
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
p
[
i
]
=
p
[
i
]
+
1
;
}
}
int
main
(
void
)
{
int
i
;
int
a
[
6
]
=
{
0
,
1
,
2
,
3
,
4
,
5
};
i
=
sizeof
(
a
)
/
sizeof
(
int
);
fun1
(
a
,
i
);
fun2
(
a
,
i
);
return
(
0
);
}
BM-GJB8114-2013/A-2-7-1/A-2-7-1-bad.cpp
0 → 100644
View file @
2a291a73
#include <iostream>
using
namespace
std
;
class
Foo
{
public:
Foo
(
void
);
~
Foo
(
void
);
void
SetVar
(
int
var
)
//提示1
{
a
=
var
;
}
private:
int
a
;
};
Foo
::
Foo
(
void
)
{
a
=
0
;
}
Foo
::~
Foo
(
void
)
{
}
int
main
(
void
)
{
Foo
thef
;
thef
.
SetVar
(
2
);
return
(
0
);
}
BM-GJB8114-2013/A-2-7-1/A-2-7-1-good.cpp
0 → 100644
View file @
2a291a73
#include <iostream>
using
namespace
std
;
class
Foo
{
public:
Foo
(
void
);
~
Foo
(
void
);
void
SetVar
(
int
var
);
//遵循1
private:
int
a
;
};
Foo
::
Foo
(
void
)
{
a
=
0
;
}
Foo
::~
Foo
(
void
)
{
}
void
Foo
::
SetVar
(
int
var
)
{
a
=
var
;
}
int
main
(
void
)
{
Foo
thef
;
thef
.
SetVar
(
2
);
return
(
0
);
}
BM-GJB8114-2013/A-2-8-2/A-2-8-2-bad.cpp
0 → 100644
View file @
2a291a73
#include <iostream>
using
namespace
std
;
int
main
(
void
)
{
int
i
;
try
{
int
a1
=
1
;
int
*
a2
=
new
int
(
2
);
if
(
i
>
10
)
{
throw
&
a1
;
}
else
{
throw
a2
;
}
}
catch
(
int
*
b
)
{
cout
<<
b
<<
endl
;
//提示1:是否需要释放动态分配的内存?
}
return
(
0
);
}
BM-GJB8114-2013/A-2-9-2/A-2-9-2-bad.cpp
0 → 100644
View file @
2a291a73
//构造测试例
using
namespace
std
;
int
main
(
void
)
{
int
a
=
0
;
const
int
*
p1
=
&
a
;
//推荐,指针常数
int
const
*
p2
=
&
a
;
//不推荐,指针常数
int
*
const
p3
=
&
a
;
//只能如此,常数指针
int
const
b
=
1
;
//不推荐
const
int
c
=
2
;
//推荐
return
(
0
);
}
BM-GJB8114-2013/A-2-9-4/A-2-9-4-bad.cpp
0 → 100644
View file @
2a291a73
#include "iostream.h" //提示1
using
namespace
std
;
int
main
(
void
)
{
cout
<<
"Hello!"
<<
endl
;
return
(
0
);
}
BM-GJB8114-2013/A-2-9-4/A-2-9-4-good.cpp
0 → 100644
View file @
2a291a73
#include <iostream> //遵循1
using
namespace
std
;
int
main
(
void
)
{
cout
<<
"Hello!"
<<
endl
;
return
(
0
);
}
BM-GJB8114-2013/R-1-1-1/R-1-1-1-bad.c
0 → 100644
View file @
2a291a73
#define long 100 //违背1
int
main
(
void
)
{
int
i
;
i
=
long
;
return
(
0
);
}
BM-GJB8114-2013/R-1-1-1/R-1-1-1-bad.cpp
0 → 100644
View file @
2a291a73
#define long 100 //违背1
int
main
(
void
)
{
int
i
;
i
=
long
;
return
(
0
);
}
BM-GJB8114-2013/R-1-1-1/R-1-1-1-good.c
0 → 100644
View file @
2a291a73
#define LONG_NUM 100 //遵循1
int
main
(
void
)
{
int
i
;
i
=
LONG_NUM
;
return
(
0
);
}
BM-GJB8114-2013/R-1-1-1/R-1-1-1-good.cpp
0 → 100644
View file @
2a291a73
#define LONG_NUM 100 //遵循1
int
main
(
void
)
{
int
i
;
i
=
LONG_NUM
;
return
(
0
);
}
Prev
1
2
3
4
5
…
32
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment