ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題ZEROJUDGE C++程式解題

 


戰昇 發表在 痞客邦 留言(0) 人氣()

此題為出自zerojidge 基礎題a038 數字翻轉

點我觀看題目

以下是我寫出來的答案


(一)沒有struct版本

#include 
using namespace std;

int reverseNumber(int num);

int main() 
{
    int num;
    cin >> num;
        int reversedNum;
        reversedNum=reverseNumber(num);

    cout << reversedNum << endl;

    return 0;
}

int reverseNumber(int num)
{
        // 當數字為 0 時直接輸出 0
    if (num == 0) 
        {
        cout << num << endl;
        return 0;
    }

    // 反轉數字同時忽略尾部的零
    int reversedNum = 0;
    while (num > 0) 
        {
        int digit = num % 10;  // 獲取最後一位數
        num /= 10;  // 移除最後一位數

        if (digit == 0 && reversedNum == 0) 
                {
            // 忽略尾部的零
            continue;
        }

        reversedNum = reversedNum * 10 + digit; // 將數字反轉
    }
    return reversedNum;

}


點我看程式碼


 

(二)有struct版本

戰昇 發表在 痞客邦 留言(0) 人氣()

此題為出自zerojidge 基礎題a024

點我觀看題目

以下是我寫出來的答案


(一)沒有class版本

#include <iostream>
using namespace std;

// 函數:計算最大公因數
int gcd(int num1, int num2);

int main() 
{
    int num1, num2;
    cin >> num1 >> num2;

    cout  << gcd(num1, num2) << endl;

    return 0;
}

// 實現 gcd 函數
int gcd(int num1, int num2) 
{
    while (num2 != 0) 
        {
        int temp = num2;
        num2 = num1 % num2;
        num1 = temp;
    }
    return a;  // 返回計算結果
}


點我看程式碼


 

(二)有class版本

戰昇 發表在 痞客邦 留言(0) 人氣()

此題為出自zerojidge 基礎題a022

點我觀看題目

以下是我寫出來的答案




#include <iostream>
using namespace std;

// 定義 isPalindrome 函數
void isPalindrome(string word) ;

int main() 
{
    string word;
    cin >> word;  // 正確讀取字串
    isPalindrome(word);  // 調用 isPalindrome 函數
    return 0;
}

void isPalindrome(string word) 
{
    int length = word.length();
    bool isPalin = true;

    for (int i = 0; i < length / 2; i++) 
        {
        if (word[i] != word[length - 1 - i]) 
                {
            isPalin = false; // 若找到不匹配的字符,則非迴文
            break;
        }
    }

    if (isPalin) 
        {
        cout << "yes";
    } 
        else 
        {
        cout << "no";
    }
}






點我看程式碼

 

戰昇 發表在 痞客邦 留言(0) 人氣()

此題為出自zerojidge 基礎題a015

點我觀看題目

以下是我寫出來的答案



#include <iostream>
using namespace std;

int main() 
{
    int row, column;

    // 當還有輸入時持續處理
    while (cin >> row >> column) 
        {
        // 動態分配二維陣列
        int** matrix = new int*[row];
        for (int i = 0; i < row; i++) 
                {
            matrix[i] = new int[column];
        }

        // 從輸入讀取矩陣元素
        for (int i = 0; i < row; i++) 
                {
            for (int j = 0; j < column; j++) 
                        {
                cin >> matrix[i][j];
            }
        }

        // 轉置矩陣
        for (int i = 0; i < column; i++) {
            for (int j = 0; j < row; j++) {
                cout << matrix[j][i] << " ";
            }
            cout << endl;
        }

        delete[] matrix;
        matrix=nullptr;
    }

    return 0;
}




點我看程式碼

 

戰昇 發表在 痞客邦 留言(0) 人氣()

以下是我整理的ZEROJUDGE題目解析
有問題都可以底下留言

 

基本題庫

 
 

 

戰昇 發表在 痞客邦 留言(0) 人氣()

以下是我目前寫的基本題庫參考答案

 
 
 
a004. 文文的求婚
a005. Eva 的回家作業
 

 


戰昇 發表在 痞客邦 留言(0) 人氣()

點我看題目

class Solution 
{
public:
    string mergeAlternately(string word1, string word2) 
    {
        string result="";
        int length1 = word1.length(), length2 = word2.length();
        int minLength = min(length1, length2);

        // 使用 for 循环交替添加字符
        for (int i = 0; i < minLength; i++) 
        {
            result += word1[i];
            result += word2[i];
        }

        // 添加剩余的字符
        for (int i = minLength; i < length1; i++) 
        {
            result += word1[i];
        }
        for (int i = minLength; i < length2; i++) 
        {
            result += word2[i];
        }

        return result;
    }
};

戰昇 發表在 痞客邦 留言(0) 人氣()

 

此題為出自zerojidge 基礎題005

點我觀看題目

以下是我寫出來的答案




#include <iostream>
using namespace std;

int main() 
{
    //先確認會有幾個數列 
    int n;
    cin >> n;

    //依次輸入每個數列的四個數字 
    for (int i = 0; i < n; i++) 
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;

        // 判斷數列類型
        if (b - a == c - b && c - b == d - c) 
        {
            // 等差數列
            int diff = b - a;
            cout << a << " " << b << " " << c << " " << d << " " << d + diff << endl;
        } 
        else if (b / a == c / b && c / b == d / c) 
        {
            // 等比數列
            int ratio = b / a;
            cout << a << " " << b << " " << c << " " << d << " " << d * ratio << endl;
        }
    }
    return 0;
}



戰昇 發表在 痞客邦 留言(0) 人氣()

此題為出自zerojidge 基礎題004

點我觀看題目

以下是我寫出來的答案

 


#include <iostream>
using namespace std;


int main()
{
        int year;//因為year是整數 
        
        while(cin>>year)//只要使用者持續輸入,就會一直執行迴圈 
        {
        //此為判斷是否為閏年 
                if((year%4==0&&year%100!=0)||year%400==0)
                        cout<<"閏年"<<"\n";//記得要用換行符號 
                else
                        cout<<"平年"<<"\n";
                
        }
        return 0;

}

戰昇 發表在 痞客邦 留言(0) 人氣()

PROBLEM 01

 

 

 

 

戰昇 發表在 痞客邦 留言(0) 人氣()

PROBLEM 01

 

 

 

 

戰昇 發表在 痞客邦 留言(0) 人氣()

PROBLEM 01

(1 point)

Evaluate the integral using the indicated trigonometric substitution.

10x39x2dx,x=3sin(θ)∫10�39−�2��,�=3sin⁡(�)

 

文章標籤

戰昇 發表在 痞客邦 留言(0) 人氣()

PROBLEM 01

(

1 point)

Find the most general antiderivative of f(x)=7x348x43.�(�)=7�34−8�43.

Note: Any arbitrary constants used must be an upper-case "C".

文章標籤

戰昇 發表在 痞客邦 留言(0) 人氣()

以下為試教內容


戰昇 發表在 痞客邦 留言(0) 人氣()

以下是家教紀錄總整理


戰昇 發表在 痞客邦 留言(0) 人氣()

PROBLEM 01

(1 point)

Given that limxaf(x)=0, limxag(x)=0, limxah(x)=1, limxap(x)=, limxaq(x)=lim�→��(�)=0, lim�→��(�)=0, lim�→�ℎ(�)=1, lim�→��(�)=∞, lim�→��(�)=∞.

Which of the following limits are indeterminate forms? For those that are not an indeterminate form, evaluate the limit where possible. Enter I to indicate an indeterminate form, INF for positive infinity, NINF for negative infinity, and D for the limit does not exist or we don't have enough information to determine the limit.

(a) limxa[f(x)]g(x)=lim�→�[�(�)]�(�)= 

文章標籤

戰昇 發表在 痞客邦 留言(0) 人氣()

PROBLEM 01

(1 point) Differentiate f(t)=ln(cost)�(�)=ln⁡(cos⁡�).

f(t)=�′(�)= 

台大WEBWORK 微積分1:11~14組 【3.6: Pr

文章標籤

戰昇 發表在 痞客邦 留言(0) 人氣()

PROBLEM 01

(1 point)

Differentiate y=103x2�=103−�2.

y=�′= 

文章標籤

戰昇 發表在 痞客邦 留言(0) 人氣()

PROBLEM 01

(1 point) Find dy/dx��/�� by implicit differentiation.

tan(xy)=y1+x2tan⁡(�−�)=�1+�2

 

dydx=����= 

文章標籤

戰昇 發表在 痞客邦 留言(0) 人氣()