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
452 additions
and
0 deletions
+452
-0
BM-GJB8114-2013/R-1-3-2/R-1-3-2-bad.cpp
BM-GJB8114-2013/R-1-3-2/R-1-3-2-bad.cpp
+26
-0
BM-GJB8114-2013/R-1-3-2/R-1-3-2-good.c
BM-GJB8114-2013/R-1-3-2/R-1-3-2-good.c
+26
-0
BM-GJB8114-2013/R-1-3-2/R-1-3-2-good.cpp
BM-GJB8114-2013/R-1-3-2/R-1-3-2-good.cpp
+26
-0
BM-GJB8114-2013/R-1-3-3/R-1-3-3-bad.c
BM-GJB8114-2013/R-1-3-3/R-1-3-3-bad.c
+21
-0
BM-GJB8114-2013/R-1-3-3/R-1-3-3-bad.cpp
BM-GJB8114-2013/R-1-3-3/R-1-3-3-bad.cpp
+21
-0
BM-GJB8114-2013/R-1-3-3/R-1-3-3-good.c
BM-GJB8114-2013/R-1-3-3/R-1-3-3-good.c
+23
-0
BM-GJB8114-2013/R-1-3-3/R-1-3-3-good.cpp
BM-GJB8114-2013/R-1-3-3/R-1-3-3-good.cpp
+23
-0
BM-GJB8114-2013/R-1-3-4/R-1-3-4-bad.c
BM-GJB8114-2013/R-1-3-4/R-1-3-4-bad.c
+23
-0
BM-GJB8114-2013/R-1-3-4/R-1-3-4-bad.cpp
BM-GJB8114-2013/R-1-3-4/R-1-3-4-bad.cpp
+23
-0
BM-GJB8114-2013/R-1-3-4/R-1-3-4-good.c
BM-GJB8114-2013/R-1-3-4/R-1-3-4-good.c
+23
-0
BM-GJB8114-2013/R-1-3-4/R-1-3-4-good.cpp
BM-GJB8114-2013/R-1-3-4/R-1-3-4-good.cpp
+23
-0
BM-GJB8114-2013/R-1-3-5/R-1-3-5-bad.c
BM-GJB8114-2013/R-1-3-5/R-1-3-5-bad.c
+16
-0
BM-GJB8114-2013/R-1-3-5/R-1-3-5-bad.cpp
BM-GJB8114-2013/R-1-3-5/R-1-3-5-bad.cpp
+16
-0
BM-GJB8114-2013/R-1-3-5/R-1-3-5-good.c
BM-GJB8114-2013/R-1-3-5/R-1-3-5-good.c
+21
-0
BM-GJB8114-2013/R-1-3-5/R-1-3-5-good.cpp
BM-GJB8114-2013/R-1-3-5/R-1-3-5-good.cpp
+21
-0
BM-GJB8114-2013/R-1-3-6/R-1-3-6-bad.c
BM-GJB8114-2013/R-1-3-6/R-1-3-6-bad.c
+24
-0
BM-GJB8114-2013/R-1-3-6/R-1-3-6-bad.cpp
BM-GJB8114-2013/R-1-3-6/R-1-3-6-bad.cpp
+24
-0
BM-GJB8114-2013/R-1-3-6/R-1-3-6-good.c
BM-GJB8114-2013/R-1-3-6/R-1-3-6-good.c
+25
-0
BM-GJB8114-2013/R-1-3-6/R-1-3-6-good.cpp
BM-GJB8114-2013/R-1-3-6/R-1-3-6-good.cpp
+25
-0
BM-GJB8114-2013/R-1-3-7/R-1-3-7-bad.c
BM-GJB8114-2013/R-1-3-7/R-1-3-7-bad.c
+22
-0
No files found.
BM-GJB8114-2013/R-1-3-2/R-1-3-2-bad.cpp
0 → 100644
View file @
2a291a73
#include <stdlib.h>
int
fun
(
int
para1
,
int
para2
);
int
main
(
void
)
{
int
a
=
2
,
b
=
1
,
c
=
0
;
if
(
NULL
==
fun
)
//违背1
{
return
-
1
;
}
else
{
int
(
*
p
)
(
int
,
int
)
=
fun
;
//违背2
c
=
p
(
a
,
b
);
}
return
(
0
);
}
int
fun
(
int
para1
,
int
para2
)
{
return
(
para1
-
para2
);
}
BM-GJB8114-2013/R-1-3-2/R-1-3-2-good.c
0 → 100644
View file @
2a291a73
#include <stdlib.h>
int
fun
(
int
para1
,
int
para2
);
int
main
(
void
)
{
int
a
=
2
,
b
=
1
,
c
=
0
;
if
(
NULL
==
&
fun
)
//遵循1
{
return
-
1
;
}
else
{
int
(
*
p
)
(
int
,
int
)
=
&
fun
;
//遵循2
c
=
p
(
a
,
b
);
}
return
(
0
);
}
int
fun
(
int
para1
,
int
para2
)
{
return
(
para1
-
para2
);
}
BM-GJB8114-2013/R-1-3-2/R-1-3-2-good.cpp
0 → 100644
View file @
2a291a73
#include <stdlib.h>
int
fun
(
int
para1
,
int
para2
);
int
main
(
void
)
{
int
a
=
2
,
b
=
1
,
c
=
0
;
if
(
NULL
==
&
fun
)
//遵循1
{
return
-
1
;
}
else
{
int
(
*
p
)
(
int
,
int
)
=
&
fun
;
//遵循2
c
=
p
(
a
,
b
);
}
return
(
0
);
}
int
fun
(
int
para1
,
int
para2
)
{
return
(
para1
-
para2
);
}
BM-GJB8114-2013/R-1-3-3/R-1-3-3-bad.c
0 → 100644
View file @
2a291a73
unsigned
int
pfun
(
unsigned
int
*
pa
);
int
main
(
void
)
{
unsigned
int
data
;
unsigned
int
result
;
result
=
pfun
(
&
data
);
return
(
0
);
}
unsigned
int
pfun
(
unsigned
int
*
pa
)
{
static
unsigned
int
i
=
10
;
i
=
i
+
1
;
pa
=
&
i
;
//违背1
return
i
;
}
BM-GJB8114-2013/R-1-3-3/R-1-3-3-bad.cpp
0 → 100644
View file @
2a291a73
unsigned
int
pfun
(
unsigned
int
*
pa
);
int
main
(
void
)
{
unsigned
int
data
;
unsigned
int
result
;
result
=
pfun
(
&
data
);
return
(
0
);
}
unsigned
int
pfun
(
unsigned
int
*
pa
)
{
static
unsigned
int
i
=
10
;
i
=
i
+
1
;
pa
=
&
i
;
//违背1
return
i
;
}
BM-GJB8114-2013/R-1-3-3/R-1-3-3-good.c
0 → 100644
View file @
2a291a73
#include <stdlib.h>
unsigned
int
pfun
(
unsigned
int
**
pa
);
int
main
(
void
)
{
unsigned
int
*
data
=
NULL
;
unsigned
int
result
;
result
=
pfun
(
&
data
);
return
(
0
);
}
unsigned
int
pfun
(
unsigned
int
**
pa
)
{
static
unsigned
int
i
=
10
;
i
=
i
+
1
;
*
pa
=
&
i
;
//遵循1
return
i
;
}
BM-GJB8114-2013/R-1-3-3/R-1-3-3-good.cpp
0 → 100644
View file @
2a291a73
#include <stdlib.h>
unsigned
int
pfun
(
unsigned
int
**
pa
);
int
main
(
void
)
{
unsigned
int
*
data
=
NULL
;
unsigned
int
result
;
result
=
pfun
(
&
data
);
return
(
0
);
}
unsigned
int
pfun
(
unsigned
int
**
pa
)
{
static
unsigned
int
i
=
10
;
i
=
i
+
1
;
*
pa
=
&
i
;
//遵循1
return
i
;
}
BM-GJB8114-2013/R-1-3-4/R-1-3-4-bad.c
0 → 100644
View file @
2a291a73
#include <stdlib.h>
unsigned
int
*
pfun
(
unsigned
int
*
pa
);
int
main
(
void
)
{
unsigned
int
data
;
unsigned
int
*
result
=
NULL
;
result
=
pfun
(
&
data
);
return
(
0
);
}
unsigned
int
*
pfun
(
unsigned
int
*
pa
)
{
unsigned
int
temp
=
0
;
*
pa
=
10
;
temp
=
*
pa
;
return
&
temp
;
//违背1
}
BM-GJB8114-2013/R-1-3-4/R-1-3-4-bad.cpp
0 → 100644
View file @
2a291a73
#include <stdlib.h>
unsigned
int
*
pfun
(
unsigned
int
*
pa
);
int
main
(
void
)
{
unsigned
int
data
;
unsigned
int
*
result
=
NULL
;
result
=
pfun
(
&
data
);
return
(
0
);
}
unsigned
int
*
pfun
(
unsigned
int
*
pa
)
{
unsigned
int
temp
=
0
;
*
pa
=
10
;
temp
=
*
pa
;
return
&
temp
;
//违背1
}
BM-GJB8114-2013/R-1-3-4/R-1-3-4-good.c
0 → 100644
View file @
2a291a73
#include <stdlib.h>
unsigned
int
*
pfun
(
unsigned
int
*
pa
);
unsigned
int
Gdata
=
0
;
int
main
(
void
)
{
unsigned
int
data
;
unsigned
int
*
result
=
NULL
;
result
=
pfun
(
&
data
);
return
(
0
);
}
unsigned
int
*
pfun
(
unsigned
int
*
pa
)
{
*
pa
=
10
;
Gdata
=
*
pa
;
return
&
Gdata
;
//遵循1
}
BM-GJB8114-2013/R-1-3-4/R-1-3-4-good.cpp
0 → 100644
View file @
2a291a73
#include <stdlib.h>
unsigned
int
*
pfun
(
unsigned
int
*
pa
);
unsigned
int
Gdata
=
0
;
int
main
(
void
)
{
unsigned
int
data
;
unsigned
int
*
result
=
NULL
;
result
=
pfun
(
&
data
);
return
(
0
);
}
unsigned
int
*
pfun
(
unsigned
int
*
pa
)
{
*
pa
=
10
;
Gdata
=
*
pa
;
return
&
Gdata
;
//遵循1
}
BM-GJB8114-2013/R-1-3-5/R-1-3-5-bad.c
0 → 100644
View file @
2a291a73
#include <malloc.h>
#include <stdlib.h>
int
main
(
void
)
{
int
*
x
=
NULL
;
int
*
y
=
(
int
*
)
malloc
(
sizeof
(
int
)
);
*
x
=
1
;
//违背1
free
(
x
);
//违背2
free
(
y
);
free
(
y
);
//违背3
return
(
0
);
}
BM-GJB8114-2013/R-1-3-5/R-1-3-5-bad.cpp
0 → 100644
View file @
2a291a73
#include <malloc.h>
#include <stdlib.h>
int
main
(
void
)
{
int
*
x
=
NULL
;
int
*
y
=
(
int
*
)
malloc
(
sizeof
(
int
)
);
*
x
=
1
;
//违背1
free
(
x
);
//违背2
free
(
y
);
free
(
y
);
//违背3
return
(
0
);
}
BM-GJB8114-2013/R-1-3-5/R-1-3-5-good.c
0 → 100644
View file @
2a291a73
#include <malloc.h>
#include <stdlib.h>
int
main
(
void
)
{
int
*
x
=
(
int
*
)
malloc
(
sizeof
(
int
)
);
int
*
y
=
(
int
*
)
malloc
(
sizeof
(
int
)
);
if
(
(
NULL
!=
x
)
||
(
NULL
!=
y
)
)
{
*
x
=
1
;
//遵循1
free
(
x
);
//遵循2
free
(
y
);
//遵循3
}
else
{
//...
}
return
(
0
);
}
BM-GJB8114-2013/R-1-3-5/R-1-3-5-good.cpp
0 → 100644
View file @
2a291a73
#include <malloc.h>
#include <stdlib.h>
int
main
(
void
)
{
int
*
x
=
(
int
*
)
malloc
(
sizeof
(
int
)
);
int
*
y
=
(
int
*
)
malloc
(
sizeof
(
int
)
);
if
(
(
NULL
!=
x
)
||
(
NULL
!=
y
)
)
{
*
x
=
1
;
//遵循1
free
(
x
);
//遵循2
free
(
y
);
//遵循3
}
else
{
//...
}
return
(
0
);
}
BM-GJB8114-2013/R-1-3-6/R-1-3-6-bad.c
0 → 100644
View file @
2a291a73
#include <malloc.h>
#include <stdlib.h>
int
main
(
void
)
{
int
*
x
=
(
int
*
)
malloc
(
sizeof
(
int
)
);
if
(
NULL
!=
x
)
{
*
x
=
1
;
//......
free
(
x
);
//违背1
}
else
{
return
(
-
1
);
}
//......
return
(
0
);
}
BM-GJB8114-2013/R-1-3-6/R-1-3-6-bad.cpp
0 → 100644
View file @
2a291a73
#include <malloc.h>
#include <stdlib.h>
int
main
(
void
)
{
int
*
x
=
(
int
*
)
malloc
(
sizeof
(
int
)
);
if
(
NULL
!=
x
)
{
*
x
=
1
;
//......
free
(
x
);
//违背1
}
else
{
return
(
-
1
);
}
//......
return
(
0
);
}
BM-GJB8114-2013/R-1-3-6/R-1-3-6-good.c
0 → 100644
View file @
2a291a73
#include <malloc.h>
#include <stdlib.h>
int
main
(
void
)
{
int
*
x
=
(
int
*
)
malloc
(
sizeof
(
int
)
);
if
(
NULL
!=
x
)
{
*
x
=
1
;
//......
free
(
x
);
x
=
NULL
;
//遵循1
}
else
{
return
(
-
1
);
}
//......
return
(
0
);
}
BM-GJB8114-2013/R-1-3-6/R-1-3-6-good.cpp
0 → 100644
View file @
2a291a73
#include <malloc.h>
#include <stdlib.h>
int
main
(
void
)
{
int
*
x
=
(
int
*
)
malloc
(
sizeof
(
int
)
);
if
(
NULL
!=
x
)
{
*
x
=
1
;
//......
free
(
x
);
x
=
NULL
;
//遵循1
}
else
{
return
(
-
1
);
}
//......
return
(
0
);
}
BM-GJB8114-2013/R-1-3-7/R-1-3-7-bad.c
0 → 100644
View file @
2a291a73
#include <malloc.h>
#include <stdlib.h>
int
main
(
void
)
{
int
*
x
;
//违背1
//...
x
=
(
int
*
)
malloc
(
sizeof
(
int
)
);
if
(
NULL
!=
x
)
{
*
x
=
1
;
}
else
{
return
(
-
1
);
}
return
(
0
);
}
Prev
1
…
9
10
11
12
13
14
15
16
17
…
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