-
Notifications
You must be signed in to change notification settings - Fork 54
第二次任务 #157
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
James-Tao
wants to merge
7
commits into
TECHF5VE:master
Choose a base branch
from
James-Tao:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
第二次任务 #157
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
80f3a5f
第二次任务
James-Tao cd601e3
Merge branch 'master' of https://github.com/Zeppeli-Tao/TechMap-Works
James-Tao cf1ff94
第二次任务
James-Tao 458768e
第二次任务第三次修改
James-Tao 4ee6f49
第二次任务第三次修改
James-Tao 458971f
Merge pull request #1 from TECHF5VE/master
James-Tao 95c1fec
第三次任务
James-Tao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # 第二次任务总结 | ||
|
|
||
| **1、学习和使用指针与数组** | ||
|
|
||
| **2、学习了时间复杂度与空间复杂度的概念** | ||
|
|
||
| **3、学习了动态数组的概念** | ||
|
|
||
| **4、了解了递归的概念** | ||
|
|
||
| ***** | ||
|
|
||
| ## 出现的问题 | ||
|
|
||
| **1、开始时未弄明白动态数组的概念** | ||
|
|
||
| **2、多重指针的含义** | ||
|
|
||
| **3、不知该怎样去优化第一题的复杂度问题** | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| #include <iostream> | ||
| using namespace std; | ||
| //第一道 | ||
| void text01(int m, int n, int q, int* arrA, int* arrB) | ||
| { | ||
| int i, j; | ||
| i = m - 1; | ||
| j = n - 1; | ||
| while (i >= 0 && j >= 0) | ||
| { | ||
| if (arrA[i] >= arrB[j]) //从后向前排序,将较大的值赋给A。 | ||
| { | ||
| arrA[i + j + 1] = arrA[i]; | ||
| i--; | ||
| } | ||
| else | ||
| { | ||
| arrA[i + j + 1] = arrB[j]; | ||
| j--; | ||
| } | ||
| while (j >= 0)//当B中有剩余的值时,将剩余的值赋到A中 | ||
| //若剩余的是A中的值,则直接在数组A中 | ||
| { | ||
| arrA[j] = arrB[j]; | ||
| } | ||
|
|
||
| } | ||
| } | ||
| //第二道 | ||
| void text02(int** matrix, int n) | ||
| { | ||
| matrix = new int* [n]; | ||
| for (int i = 0; i < n; i++) | ||
| { | ||
| matrix[i] = new int[n]; | ||
| } | ||
| cout << "翻转前:" << endl; | ||
| for (int i = 0; i < n; i++) | ||
|
|
||
| { | ||
| for (int j = 0; j < n; j++) | ||
| { | ||
|
|
||
| matrix[i][j] = i * n + j + 1; | ||
| cout << matrix[i][j] << "\t"; | ||
| } | ||
| cout << endl; | ||
| } | ||
| for (int i = 0; i < n / 2; i++) | ||
| { | ||
| for (int j = 0; j < n; j++) | ||
| { | ||
| int temp = matrix[i][j]; | ||
| matrix[i][j] = matrix[n - i - 1][j]; | ||
| matrix[n - i - 1][j] = temp; | ||
|
|
||
| } | ||
| } | ||
| //对角线翻转 | ||
| for (int i = 0; i < n; i++) | ||
| { | ||
| for (int j = 0; j < i; j++) | ||
| { | ||
| int temp = matrix[i][j]; | ||
| matrix[i][j] = matrix[j][i]; | ||
| matrix[j][i] = temp; | ||
| } | ||
| } | ||
| cout << "翻转后:" << endl; | ||
| for (int i = 0; i < n; i++) | ||
|
|
||
| { | ||
| for (int j = 0; j < n; j++) | ||
| { | ||
|
|
||
| cout << matrix[i][j] << "\t"; | ||
| } | ||
| cout << endl; | ||
| } | ||
| } | ||
| //第三道 | ||
| void text03(int* a, int n) | ||
| { | ||
| int size = 10000; | ||
| int* arr = new int[size]; | ||
| int n = 0; | ||
| cin >> n; | ||
| for (int i = 0; i < n; i++) | ||
| { | ||
| arr[i] = i; | ||
| cout << arr[i] << " "; | ||
| } | ||
| } | ||
| //第四道 | ||
| int* text04(int n) | ||
| { | ||
| cin >> n; | ||
| int* arr = new int[n]; | ||
| for (int i = 0; i < n; i++) | ||
| { | ||
| arr[i] = i + 1; | ||
| } | ||
|
|
||
| for (int i = 0; i < n; i++) | ||
| { | ||
| cout << arr[i] << "\t"; | ||
| } | ||
| return arr; | ||
| } | ||
| //第五道 | ||
| int** text05(int m,int n) | ||
| { | ||
| int m = 0; | ||
| int n = 0; | ||
| cout << "请输入排数: "; | ||
| cin >> m; | ||
| cout << "请输入列数: "; | ||
| cin >> n; | ||
| int** arr = new int* [m]; | ||
| for (int i = 0; i < m; i++) | ||
| { | ||
| arr[i] = new int[n]; | ||
| } | ||
| for (int i = 0; i < m; i++) | ||
|
|
||
| { | ||
| for (int j = 0; j < n; j++) | ||
| { | ||
| arr[i][j] = i * n + j; //若使用指针则为*(*(arr+i)+j) cin >> arr[i][j] | ||
| cout << arr[i][j] << "\t"; | ||
| } | ||
| cout << endl; | ||
| } | ||
| for (int i = 0; i < m; i++) | ||
| { | ||
| delete[] arr[i]; | ||
| } | ||
| delete[] arr; | ||
| } | ||
| //第六道 | ||
| int climbstairs(int n) | ||
| { | ||
| if (n == 0) | ||
| { | ||
| return 0; | ||
| } | ||
| else if (n == 1) | ||
| { | ||
| return 1; | ||
| } | ||
| else if (n == 2) | ||
| { | ||
| return 2; | ||
| } | ||
| else { | ||
| return climbstairs(n - 1) + climbstairs(n - 2); //使用递归 | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里貌似是个死循环