“c6fc6a36035a87925bcedd27eb94b6b11c8a744e”上不存在“...tests/git@gitcode.net:paddlepaddle/PaddleDetection.git”
提交 e4861186 编写于 作者: L luxin

file node bug fixed and add 3 exercises

上级 966988fe
......@@ -47,7 +47,8 @@
}
],
"export": [
"basic_data_types.json"
"basic_data_types.json",
"is_alphabet_or_not.json"
],
"node_id": "c-4fd1baa5eb72451aa52e5ef801376f6f",
"title": "基本数据类型"
......
#include <stdio.h>
int main(int argc, char** argv)
{
char ch;
printf("请输入一个字符:");
scanf("%c", &ch);
if (('a' <= ch <= 'z') || ('A' <= ch <= 'Z'))
printf("字符 \'%c\' 是一个英文字母", ch);
else
printf("字符 \'%c\' 不是一个英文字母", ch);
return 0;
}
\ No newline at end of file
{
"type": "code_options",
"author": "卢昕",
"source": "is_alphabet_or_not.md",
"exercise_id":"bf510b82ad534ae6ba501e6872888c21"
}
\ No newline at end of file
# 英文字母判断
判断一个字符是否是英文字母。请选出错误答案。
## 答案
```c
#include <stdio.h>
int main(int argc, char** argv)
{
char ch;
printf("请输入一个字符:");
scanf("%c", &ch);
if (('a' <= ch <= 'z') || ('A' <= ch <= 'Z'))
printf("字符 \'%c\' 是一个英文字母", ch);
else
printf("字符 \'%c\' 不是一个英文字母", ch);
return 0;
}
```
## 选项
### A
```c
#include <stdio.h>
int main(int argc, char** argv)
{
char ch;
printf("请输入一个字符:");
scanf("%c", &ch);
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
printf("字符 \'%c\' 是一个英文字母", ch);
else
printf("字符 \'%c\' 不是一个英文字母", ch);
return 0;
}
```
### B
```c
#include <stdio.h>
int main(int argc, char** argv)
{
char ch;
printf("请输入一个字符:");
scanf("%c", &ch);
if ((ch >= 97 && ch <= 122) || (ch >= 65 && ch <= 90))
printf("字符 \'%c\' 是一个英文字母", ch);
else
printf("字符 \'%c\' 不是一个英文字母", ch);
return 0;
}
```
### C
```c
#include <stdio.h>
int main(int argc, char** argv)
{
char ch;
printf("请输入一个字符:");
scanf("%c", &ch);
if ((0 <= (ch - 'a') && (ch - 'a') < 26) || (0 <= (ch - 'A') && (ch - 'A') < 26))
printf("字符 \'%c\' 是一个英文字母", ch);
else
printf("字符 \'%c\' 不是一个英文字母", ch);
return 0;
}
```
......@@ -80,7 +80,8 @@
}
],
"export": [
"arithmetic_op.json"
"arithmetic_op.json",
"count_num_of_digits.json"
],
"node_id": "c-e985fb409a3a43798aa3103cebe813e3",
"title": "算术运算符与表达式"
......
#include <stdio.h>
int main(int argc, char** argv)
{
int num, count = 0;
printf("请输入一个正整数:");
scanf("%d", &num);
while (num > 0)
{
num %= 10;
count++;
}
printf("位数为:%d", count);
return 0;
}
\ No newline at end of file
{
"type": "code_options",
"author": "卢昕",
"source": "count_num_of_digits.md",
"exercise_id":"6b79121e26224651ab01251676bb5458"
}
\ No newline at end of file
# 判断正整数的位数
输入一个正整数,判断其一共包含多少位,请选出错误答案。
## 答案
```c
#include <stdio.h>
int main(int argc, char** argv)
{
int num, count = 0;
printf("请输入一个正整数:");
scanf("%d", &num);
while (num > 0)
{
num %= 10;
count++;
}
printf("位数为:%d", count);
return 0;
}
```
## 选项
### A
```c
#include <stdio.h>
int main(int argc, char** argv)
{
int num, count = 0;
printf("请输入一个正整数:");
scanf("%d", &num);
while (num > 0)
{
num = num / 10;
count = count + 1;
}
printf("位数为:%d", count);
return 0;
}
```
### B
```c
#include <stdio.h>
int main(int argc, char** argv)
{
int num, count = 0;
printf("请输入一个正整数:");
scanf("%d", &num);
while (num > 0)
{
num /= 10;
++count;
}
printf("位数为:%d", count);
return 0;
}
```
### C
```c
#include <stdio.h>
int main(int argc, char** argv)
{
int num, count = 0;
printf("请输入一个正整数:");
scanf("%d", &num);
while (num > 0)
{
num /= 10;
count += 1;
}
printf("位数为:%d", count);
return 0;
}
```
......@@ -8,7 +8,8 @@
],
"children": [],
"export": [
"recursion.json"
"recursion.json",
"loop_imitation.json"
],
"title": "函数的递归"
}
\ No newline at end of file
#include <stdio.h>
void print(int number);
int main(int argc, char **argv)
{
int num = 1;
print(num);
return 0;
}
void print(int number)
{
if (number <= 100)
{
print(++number);
printf("%d\t", number);
}
}
\ No newline at end of file
{
"type": "code_options",
"author": "卢昕",
"source": "loop_imitation.md",
"exercise_id":"bb31a0a1d8d2423d95da3b0c3176507e"
}
\ No newline at end of file
# 模拟循环
在不使用循环的情况下,使用递归按升序输出1到100的所有整数。请选出错误答案。
## 答案
```c
#include <stdio.h>
void print(int number);
int main(int argc, char **argv)
{
int num = 1;
print(num);
return 0;
}
void print(int number)
{
if (number <= 100)
{
print(++number);
printf("%d\t", number);
}
}
```
## 选项
### A
```c
#include <stdio.h>
void print(int number);
int main(int argc, char **argv)
{
int num = 1;
print(num);
return 0;
}
void print(int number)
{
if (number <= 100)
{
printf("%d\t", number);
print(number + 1);
}
}
```
### B
```c
#include <stdio.h>
void print(int number);
int main(int argc, char **argv)
{
int num = 100;
print(num);
return 0;
}
void print(int number)
{
if (number >= 1)
{
print(number - 1);
printf("%d\t", number);
}
}
```
### C
```c
#include <stdio.h>
void print(int *number);
int main(int argc, char **argv)
{
int num = 1;
print(&num);
return 0;
}
void print(int *number)
{
if (*number <= 100)
{
printf("%d\t", *number);
++(*number);
print(number);
}
}
```
......@@ -39,6 +39,10 @@
}
}
],
"export": [],
"export": [
"file01.json",
"file02.json",
"file03.json"
],
"title": "文件的基本操作"
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册