Skip to content

修改编码格式统一为UTF-8, 修复了克隆仓库到本地后中文注释可能显示异常的问题 #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 1.计算导论与C语言基础/week06/01_苹果和虫子.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ int main()
int n = 0;
double x = 0, y = 0;
cin >> n >> x >> y;
int ans = n - y / x; // ע������n��ǿ������ת��Ϊdouble��
ans = ans < 0 ? 0 : ans; // ʣ��ƻ��������СΪ0
int ans = n - y / x; // 注意这里n被强制类型转化为double!
ans = ans < 0 ? 0 : ans; // 剩余苹果个数最小为0
cout << ans << endl;
return 0;
}
2 changes: 1 addition & 1 deletion 1.计算导论与C语言基础/week06/02_大象喝水.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ int main()
cin >> h >> r;
float pi = 3.14159;
double v = pi * r * r * h;
int ans = ceil(20000 / v); // ����ȡ��
int ans = ceil(20000 / v); // 向上取整
cout << ans << endl;
return 0;
}
Expand Down
14 changes: 7 additions & 7 deletions 1.计算导论与C语言基础/week06/03_最高的分数.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
��ߵķ���
最高的分数

����
描述

����ʦ���ڵġ�������ۡ����ſ����п��Ըոս���������֪��������ȡ�õ���߷�������Ϊ�����Ƚ϶࣬������������齻������������ȽϷ��㡣���ܰ�����ʦ������������
孙老师讲授的《计算概论》这门课期中考试刚刚结束,他想知道考试中取得的最高分数。因为人数比较多,他觉得这件事情交给计算机来做比较方便。你能帮孙老师解决这个问题吗?

����
输入

�������У���һ��Ϊ����n��1 <= n < 100������ʾ�μ���ο��Ե�����.�ڶ�������n��ѧ���ijɼ�������������֮���õ����ո���������гɼ���Ϊ0��100֮���������
输入两行,第一行为整数n(1 <= n < 100),表示参加这次考试的人数.第二行是这n个学生的成绩,相邻两个数之间用单个空格隔开。所有成绩均为0到100之间的整数。

���
输出

���һ������������ߵijɼ���
输出一个整数,即最高的成绩。
*/

#include <iostream>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int main()
return 0;
}

/* ԭ�汾
/* 原版本
#include <iostream>
using namespace std;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ int main()
{
int n = 0, k = 0;
cin >> n >> k;
// û�и�n�ķ�Χ�����Զ�̬��������
// 没有给n的范围,所以动态创建数组
int *a = new int[n];

for (int i = 0; i < n; i++)
cin >> a[i];

for (int i = 0; i < n; i++)
{
// �ҵ���a[i]��ĸ�������Ϊk-1��a[i]�ǵ�k�����
// 找到比a[i]大的个数,若为k-1则a[i]是第k大的数
int bigger = 0;
for (int j = 0; j < n; j++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ int main()
{
int money = 0;
cin >> money;
// ������洢��������Ӧ������
// 用数组存储找零面额及对应的数量
int a[6] = { 100, 50, 20, 10, 5, 1 };
int n[6];

Expand Down
4 changes: 2 additions & 2 deletions 1.计算导论与C语言基础/week07/分数求和.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ int main()
int n = 0;
cin >> n;

int sumn = 0, sumd = 1; // ������ sum/sumd
int sumn = 0, sumd = 1; // 储存结果 sum/sumd
while (n--)
{
int num, deno;
Expand All @@ -25,7 +25,7 @@ int main()
a = b%a;
b = c;
}
int gcd = b; // ���Լ��
int gcd = b; // 最大公约数

sumd /= gcd;
sumn /= gcd;
Expand Down
10 changes: 5 additions & 5 deletions 1.计算导论与C语言基础/week07/约瑟夫问题.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ int main()
break;
}

int id[300]; // id ��¼���ӵı��
int state[300]; // state ��¼����״̬��1��ʾȦ�ڣ�0��ʾȦ��
int id[300]; // id 记录猴子的编号
int state[300]; // state 记录猴子状态,1表示圈内,0表示圈外

for (int i = 0; i < n; i++)
{
id[i] = i + 1;
state[i] = 1;
}

int count = 1; // ��1��ʼ����
for (int i = 0, num = n; num != 1; i++) // num��Ȧ�ں���
int count = 1; // 从1开始报数
for (int i = 0, num = n; num != 1; i++) // num:圈内猴数
{
// i >= n ��ʾ����һȦ
// i >= n 表示绕了一圈
if (i >= n)
{
i -= n;
Expand Down
2 changes: 1 addition & 1 deletion 1.计算导论与C语言基础/week08/00_点评赛车.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int main()
bool b = (best == 4);
bool c = (best != 3);
bool d = !b;
// ֻ��һ��ר��˵��
// 只有一个专家说对
if (a + b + c + d == 1)
{
cout << best << endl;
Expand Down
14 changes: 7 additions & 7 deletions 1.计算导论与C语言基础/week10/异常细胞检测.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
����
描述

���������һ��CT��Ƭ��һ����ά�������洢�����������е�ÿ�������һ��ϸ����ÿ��ϸ������ɫ��0��255֮�䣨����0��255����һ��������ʾ�����Ƕ���һ��ϸ�����쳣ϸ����������ϸ������ɫֵ������������4��ϸ������ɫֵ��С50���ϣ�����50���������Ե�ϵ�ϸ�����Dz���⡣�������ǵ������ǣ�����һ���洢CT��Ƭ�Ķ�ά���飬д����ͳ����Ƭ���쳣ϸ������Ŀ��
我们拍摄的一张CT照片用一个二维数组来存储,假设数组中的每个点代表一个细胞。每个细胞的颜色用0到255之间(包括0和255)的一个整数表示。我们定义一个细胞是异常细胞,如果这个细胞的颜色值比它上下左右4个细胞的颜色值都小50以上(包括50)。数组边缘上的细胞我们不检测。现在我们的任务是,给定一个存储CT照片的二维数组,写程序统计照片中异常细胞的数目。

����
输入

��һ�а���һ������N��100>=N>2��.
第一行包含一个整数N(100>=N>2.

������ N �У�ÿ���� N ��0~255֮�������������֮���ÿո������
下面有 N 行,每行有 N 个0~255之间的整数,整数之间用空格隔开。

���
输出

���ֻ��һ�У�����һ��������Ϊ�쳣ϸ������Ŀ��
输出只有一行,包含一个整数,为异常细胞的数目。
*/

#include <iostream>
Expand Down
16 changes: 8 additions & 8 deletions 1.计算导论与C语言基础/week10/循环移动.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/*
����
描述

����һ��������Ҫ���������������������������������ʵ�ֶ������е���ѭ���ƶ����ٶ�����n����������Ҫʹǰ�����˳�������m��λ�ã���ʹ���m������Ϊ��ǰ���m������
给定一组整数,要求利用数组把这组数保存起来,再利用实现对数组中的数循环移动。假定共有n个整数,则要使前面各数顺序向后移m个位置,并使最后m各数变为最前面的m各数。

ע�⣬��Ҫ���������m�����������ǰn-m�����ķ���ʵ�֣�Ҳ��Ҫ����������ķ�ʽʵ�֡�
注意,不要用先输出后m个数,再输出前n-m个数的方法实现,也不要用两个数组的方式实现。

Ҫ��ֻ��һ������ķ�ʽʵ�֣�һ��Ҫ��֤��������ʱ�������˳�������������˳����һ�µġ�
要求只用一个数组的方式实现,一定要保证在输出结果时,输出的顺序和数组中数的顺序是一致的。

����
输入

���������У���һ�а���һ��������n��һ��������m���ڶ��а���n����������ÿ�����������м���һ���ո�ֿ���
输入有两行:第一行包含一个正整数n和一个正整数m,第二行包含n个正整数。每两个正整数中间用一个空格分开。

���
输出

�����һ�У�����ѭ���ƶ���������������˳�����������ÿ��������֮���ÿո�ָ���
输出有一行:经过循环移动后数组中整数的顺序依次输出,每两个整数之间用空格分隔。
*/

#include <iostream>
Expand Down
14 changes: 7 additions & 7 deletions 1.计算导论与C语言基础/week10/矩阵交换行.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
����
描述

��main�����У� ����һ��5*5�ľ�������������ݣ�������n��m��ֵ���ж�n��m�Ƿ������鷶Χ�ڣ�������ڣ������error������ڷ�Χ�ڣ���n�к�m�н������������n��m����¾���
在main函数中, 生成一个5*5的矩阵,输入矩阵数据,并输入n,m的值。判断n,m是否在数组范围内,如果不在,则输出error;如果在范围内,则将n行和m行交换,输出交换n,m后的新矩阵。

����
输入

5*5��������ݣ��Լ�n��m��ֵ��
5*5矩阵的数据,以及n和m的值。

���
输出

������ɽ����������error
如果不可交换,则输出error

����ɽ�����������¾���
如果可交换,则输出新矩阵
*/

#include <iostream>
Expand Down
12 changes: 6 additions & 6 deletions 1.计算导论与C语言基础/week12(final)/字符串插入.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
����
描述

�������ַ���str��substr��str���ַ�����������10��substr���ַ�����Ϊ3�����ַ������������ַ�����β����'\0'������substr���뵽str��ASCII�������Ǹ��ַ����棬���ж�������ֻ���ǵ�һ����
有两个字符串str和substr,str的字符个数不超过10,substr的字符个数为3。(字符个数不包括字符串结尾处的'\0'。)将substr插入到str中ASCII码最大的那个字符后面,若有多个最大则只考虑第一个。

����
输入

������������У�ÿһ��Ϊһ��������ݣ���ʽΪ
输入包括若干行,每一行为一组测试数据,格式为

str substr

���
输出

����ÿһ��������ݣ��������֮����ַ�����
对于每一组测试数据,输出插入之后的字符串。
*/

#include <iostream>
Expand Down
26 changes: 13 additions & 13 deletions 2.C程序设计进阶/week2/作业/发票统计.cpp
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
/*
����⣣3����Ʊͳ��
编程题#3:发票统计

ע�⣺ ��ʱ������: 1000ms �ڴ�����: 65536kB
注意: 总时间限制: 1000ms 内存限制: 65536kB

����
描述

��һ��С�͵ı���ϵͳ���������¹��ܣ�
有一个小型的报账系统,它有如下功能:

��1��ͳ��ÿ����������Ʊ����Ǯ��
(1)统计每个人所报发票的总钱数

��2��ͳ��ÿ�෢Ʊ����Ǯ��
(2)统计每类发票的总钱数

����ϵͳ��Ϊ���£����跢Ʊ�����A��B��C����;һ���������ˣ�ID�ֱ�Ϊ1��2��3��
将此系统简化为如下:假设发票类别共有A、B、C三种;一共有三个人,ID分别为1、2、3。

����
输入

ϵͳ����������У�ÿ�е�һ����Ϊ��ԱID�����ͣ�1��2��3�����ڶ�����Ϊ��Ʊ������(����������100)��֮���Ƕ����Ʊ����ַ��ͣ�A��B��C������Ӧ��Ʊ�������ȸ�����,������1000.0����
系统输入包含三行,每行第一个数为人员ID(整型,1或2或3),第二个数为发票总张数(张数不超过100),之后是多个发票类别(字符型,A或B或C)和相应发票金额(单进度浮点型,不超过1000.0)。

���
输出

����������У�ǰ����Ϊÿ�ˣ���ID��С���������������Ʊ��Ǯ����������λС������������Ϊÿ�෢Ʊ����Ǯ����������λС������
输出包含六行,前三行为每人(按ID由小到大输出)所报发票总钱数(保留两位小数),后三行为每类发票的总钱数(保留两位小数)。

��������
样例输入
1 5 A 1.0 A 2.0 C 1.0 B 1.0 C 1
3 3 B 1 C 2 C 1
2 4 B 1 A 1 C 1 A 1

�������
样例输出
1 6.00
2 4.00
3 4.00
Expand Down
36 changes: 18 additions & 18 deletions 2.C程序设计进阶/week2/作业/四大湖.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
/*
����⣣2���Ĵ��
编程题#2:四大湖

ע�⣺ ��ʱ������: 1000ms �ڴ�����: 65536kB
注意: 总时间限制: 1000ms 内存限制: 65536kB

����
描述

�ҹ���4��ˮ����
我国有4大淡水湖。

A˵����ͥ����󣬺������С��۶����������
A说:洞庭湖最大,洪泽湖最小,鄱阳湖第三。

B˵���������󣬶�ͥ����С��۶�����ڶ���̫��������
B说:洪泽湖最大,洞庭湖最小,鄱阳湖第二,太湖第三。

C˵���������С����ͥ��������
C说:洪泽湖最小,洞庭湖第三。

D˵��۶�������̫����С��������ڶ�����ͥ��������
D说:鄱阳湖最大,太湖最小,洪泽湖第二,洞庭湖第三。

��֪��4�����Ĵ�С������ȣ�4����ÿ�˽����һ����
已知这4个湖的大小均不相等,4个人每人仅答对一个,

���̰���۶��������ͥ����̫�����������˳��������ǵĴ�С������
请编程按照鄱阳湖、洞庭湖、太湖、洪泽湖的顺序给出他们的大小排名。

����
输入

�ޡ�
无。

���
输出

���Ϊ4�У���1��Ϊ۶�����Ĵ�С���Σ��Ӵ�С���ηֱ��ʾΪ1��2��3��4����2��3��4�зֱ�Ϊ��ͥ����̫����������Ĵ�С���Ρ�
输出为4行,第1行为鄱阳湖的大小名次,从大到小名次分别表示为1、2、3、4;第2、3、4行分别为洞庭湖、太湖、洪泽湖的大小名次。

��������
(��)
样例输入
()

�������
样例输出
3
2
1
Expand All @@ -45,7 +45,7 @@ int check(int guess[], int order[]);

int main()
{
// ˳��۶��������ͥ����̫���������
// 顺序:鄱阳湖、洞庭湖、太湖、洪泽湖
int guessA[4] = { 3,1,0,4 };
int guessB[4] = { 2,4,3,1 };
int guessC[4] = { 0,3,0,4 };
Expand Down
30 changes: 15 additions & 15 deletions 2.C程序设计进阶/week2/作业/寻找下标.cpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
/*
����⣣1��Ѱ���±�
编程题#1:寻找下标

ע�⣺ ��ʱ������: 1000ms �ڴ�����: 65536kB
注意: 总时间限制: 1000ms 内存限制: 65536kB

����
描述

��֪һ����������x[],���е�Ԫ�ر˴˶�����ͬ���ҳ��������������Ƿ���һ��Ԫ������x[i]=i�Ĺ�ϵ�������±��0��ʼ��
已知一个整数数组x[],其中的元素彼此都不相同。找出给定的数组中是否有一个元素满足x[i]=i的关系,数组下标从0开始。

�������ԣ����x[]={-2,-1,7,3,0,8},��x[3] = 3,���3���Ǵ𰸡�
举例而言,如果x[]={-2,-1,7,3,0,8},则x[3] = 3,因此3就是答案。

����
输入

��һ�а���һ������n (0 < n < 100)����ʾ������Ԫ�صĸ�����<br />�ڶ��а���n�����������α�ʾ�����е�Ԫ�ء�
第一行包含一个整数n (0 < n < 100),表示数组中元素的个数。<br />第二行包含n个整数,依次表示数组中的元素。

���
输出

���Ϊһ��������������x[i]=i��Ԫ�أ����ж��Ԫ�����㣬�����һ�������Ԫ�ء���û��Ԫ�����㣬�������N����
输出为一个整数,即满足x[i]=i的元素,若有多个元素满足,输出第一个满足的元素。若没有元素满足,则输出“N”。

��������
��һ��
样例输入
第一组
6
-2 -1 7 3 4 8
�ڶ���
第二组
6
9 9 9 9 9 9

�������
��һ��
样例输出
第一组
3
�ڶ���
第二组
N
*/
#include <iostream>
Expand Down
Loading