原创 PAT乙級 1008數組循環右移問題(C語言)

第一次提交測試點2沒通過。 試了半天,發現是當m > n的情況沒有考慮到。 所以代碼加了一行m = m % n。 #include <stdio.h> #include <stdlib.h> int main() { int

原创 PAT乙級 1006換個格式輸出(c語言)

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int main() { int n, i, len, j, k;

原创 PAT乙級 1005繼續3n+1猜想(C語言)

#include <stdio.h> #include <stdlib.h> void bubbleSort(int *p, int n) { int i, j, tmp; for(i = 0; i < n; i++) {

原创 PAT乙級 1013 數素數(C語言)

注意: 超時問題。 判斷是否爲素數的函數裏求該數的平方根,減少時間。 #include <stdio.h> #include <stdlib.h> #include <math.h> int isPrime(int n) {

原创 PAT乙級 1009說反話(C語言)

解題方法就是創建一個二維字符串數組,將讀取的單詞保存到數組中,然後倒序輸出。 經過測試,所有的測試樣例,單詞的數量最多爲8個,單詞的長度最大爲10。 #include <stdio.h> #include <stdlib.h>

原创 梯度下降算法對比

梯度下降方法總結 完整的notebook上傳到了github上:https://github.com/xichie/DeepLearning import numpy as np import matplotlib.pyplot

原创 PAT 甲級 1001(C語言)

注意幾種情況: a+b = 0 a+b = -10或-100或-1000 a+b = 1000或10000 #include <stdio.h> #include <stdlib.h> #include <string.h> i

原创 PAT1003 我要通過(C語言)

網上已經有很多解析了,就不廢話了。 主要注意一下幾點: P、A、T三個字符都要出現。(測試點2) P、T僅且出現一次。 P在T之前。 P和T之間至少有一個A。 P左邊A的數量 * P和T之間A的數量 = T右邊A的數量。 代碼

原创 PAT甲級 1002 A+B for Polynomials(C語言)

笨方法:創建一個結構體保存指數和係數。 測試點: 係數爲0的情況。不計入項數,也不輸出。 輸出格式的問題 #include <stdio.h> #include <stdlib.h> #define MAX 20 type

原创 PAT 乙級 1007素數對猜想(C語言)

#include <stdio.h> #include <stdlib.h> #include <math.h> int isPrime(int n) { int i, tmp; tmp = (int)sqrt(n); f

原创 PAT乙級 1014福爾摩斯的約會(C語言)

到現在題目也沒搞太明白,反正通過了。下面我的理解。 注意: 判斷小時數:題目中說是第2對相同字符,應該是星期數後面的相同的字符,並且要滿足: 是數字或則A~N之間。 如果是從頭開始的第二個滿足條件的字符,比如: 3485dj

原创 PAT 乙級1004 成績排名

#include <stdio.h> #include <stdlib.h> typedef struct info { char sname[11]; //注意是11個字符,多餘的1位爲'\0'。 char sno[

原创 讀取帶標點的英文段落,分詞、去重按字典順序輸出(C語言)

例如: 輸入: I love Beijing. I Love China. Oh,Beijing is the capital of China. Do you know? Cheer up!! 輸出: Beijing Cheer

原创 PAT乙級 1010一元多項式求導(C語言)

注意點: 只要判斷第一項求導後是否爲零多項式。如果是,輸出0 0;否則,依次輸出求導後非零多項式。 輸出格式問題,最後不要帶空格。 不通過可以試試這兩個測試用例: 輸入:2 3 0 2 0 1 輸出:6 2 0 1 0 0

原创 PAT乙級 1011A+B 和 C(C語言)

不知道這個題考的知識點是什麼。。。。。 #include <stdio.h> int main() { int t, i; double a, b, c; while(~scanf("%d", &t)) { for(i