commit
058820ec38
@ -0,0 +1,16 @@
|
|||||||
|
int gcd(int a, int b) {
|
||||||
|
if (a == b){ return a; }
|
||||||
|
else if (a > b) { return gcd(a - b, b); }
|
||||||
|
else return gcd(b - a, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int LF = 10;
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
int a,b;
|
||||||
|
a = getint();
|
||||||
|
b = getint();
|
||||||
|
putint(gcd(a,b));
|
||||||
|
putch(LF);
|
||||||
|
return 0;
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
float LF = 1;
|
||||||
|
const int LF = 10;
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
int a,b;
|
||||||
|
a = getint();
|
||||||
|
b = getint();
|
||||||
|
putint(gcd(a,b));
|
||||||
|
putch(LF);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Redefined Variable 重复定义变量/重复声明
|
@ -0,0 +1,17 @@
|
|||||||
|
int gcd(int a, int a) {
|
||||||
|
if (a == b){ return a; }
|
||||||
|
else if (a > b) { return gcd(a - b, b); }
|
||||||
|
else return gcd(b - a, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int LF = 10;
|
||||||
|
|
||||||
|
int main(){
|
||||||
|
int a,b;
|
||||||
|
a = getint();
|
||||||
|
b = getint();
|
||||||
|
putint(gcd(a,b));
|
||||||
|
putch(LF);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Redefined Variable 函数形参重复定义
|
@ -0,0 +1,17 @@
|
|||||||
|
int gcd(int a, int b) {
|
||||||
|
if (a == b){ return a; }
|
||||||
|
else if (a > b) { return gcd(a - b, b); }
|
||||||
|
else return gcd(b - a, a);
|
||||||
|
}
|
||||||
|
void gcd(int a) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
int main(){
|
||||||
|
int a,b;
|
||||||
|
a = getint();
|
||||||
|
b = getint();
|
||||||
|
putint(gcd(a,b));
|
||||||
|
putch(LF);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Redefined Function 函数重复定义
|
@ -0,0 +1,9 @@
|
|||||||
|
int main(){
|
||||||
|
int b;
|
||||||
|
a = getint();
|
||||||
|
b = getint();
|
||||||
|
putint(gcd(a,b));
|
||||||
|
putch(LF);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Use Undefined Variable 使用未定义变量
|
@ -0,0 +1,8 @@
|
|||||||
|
int main(){
|
||||||
|
int a = 0,b = 0;
|
||||||
|
a = test();
|
||||||
|
b = getint();
|
||||||
|
test(a,b);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Use Undefined Function 使用未定义函数
|
@ -0,0 +1,11 @@
|
|||||||
|
float test(int a, int b) {
|
||||||
|
if (a+b==1){
|
||||||
|
return a+b;
|
||||||
|
}
|
||||||
|
return 0.1;
|
||||||
|
}
|
||||||
|
int main() {
|
||||||
|
float c = test(1,1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Func Return Type Not Match 返回类型不匹配
|
@ -0,0 +1,11 @@
|
|||||||
|
int test(int a, int b) {
|
||||||
|
int d[1][2];
|
||||||
|
int c[10];
|
||||||
|
c[0.1] = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int main() {
|
||||||
|
int c = test(1,1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Array index not int 数组下标不是整数
|
@ -0,0 +1,18 @@
|
|||||||
|
int test(int a, int b) {
|
||||||
|
int i = 0;
|
||||||
|
while (i <= 10) {
|
||||||
|
i = i + 1;
|
||||||
|
if ( i == 3 ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int main() {
|
||||||
|
int c = test(1,1);
|
||||||
|
continue;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Break not in loop break语句不在循环中
|
||||||
|
|
@ -0,0 +1,18 @@
|
|||||||
|
int test(int a, int b) {
|
||||||
|
int i = 0;
|
||||||
|
while (i <= 10) {
|
||||||
|
i = i + 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
if ( i == 11 ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int main() {
|
||||||
|
int c = test(1,1);
|
||||||
|
continue;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Continue not in loop break语句不在循环中
|
||||||
|
|
@ -0,0 +1,12 @@
|
|||||||
|
int test(int a, int b) {
|
||||||
|
|
||||||
|
int c ;
|
||||||
|
c[10] = a + b;
|
||||||
|
}
|
||||||
|
int main() {
|
||||||
|
int c = test(1,1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Visit non-array variable in the form of subscript variables 对非数组变量采用下标变量的形式访问
|
||||||
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
|||||||
|
int main(){
|
||||||
|
int i = 1;
|
||||||
|
while (i < 9) {
|
||||||
|
int j = 1;
|
||||||
|
while (j < 0) {
|
||||||
|
int a = i * j * b;
|
||||||
|
c = a;
|
||||||
|
j = j + 1;
|
||||||
|
//if (j == 5) break;
|
||||||
|
}
|
||||||
|
d = j;
|
||||||
|
if (i == 5) break;
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
i = e * 5;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in new issue