崔甯甯期中考網頁檔案對照Python寫入

VScode練習程式碼

VScode截圖

CSS程式碼

h1{background-color: pink; color: white; border: 10px solid gold; text-align:center; padding: 5px}
ul{background-color: orange; color: white; font-size: 2em;line-height:1.5}
input{font-size:24px;background-color:gold;}
.monkey{font-size:36px;}

HTML程式碼

<link rel='stylesheet' href="abc.css">
<script src="abc.js"></script>
<h1>崔甯甯輸入參數</h1>
輸入k<input type="number" value="1" id="k"></input><br>
輸入m<input type="number" value="1" id="m"></input><br>
輸入n<input type="number" value="1" id="n"></input><br>
<button onclick="abc()">執行自訂函數</button>
<h1>重點</h1>
alert內建函數,自訂函數abc
<h1>崔甯甯輸出結果</h1>
<div id="out" class="monkey"></div>

JAVASCRIPT程式碼

const space=' ', slash='/', backslash='\\', cr='\n';
function row1(k,m){
    for(let i=0; i<k;i++){
        for(let ii=0; ii<m; ii++){
            for(let j=0; j<k-i-1; j++)
                out+=space;
            out+=slash;
            for(let j=0; j<2*i; j++)
                out+=space;
            out+=backslash;
            for(let j=0; j<k-i-1;j++)
                out+=space;};
    out+=cr;};};
function row2(k,m){
    for(let i=0; i<k; i++){
        for(let ii=0; ii<m; ii++){
            for(let j=0; j<i; j++)
                out+=space;
            out+=backslash;
            for(let j=0; j<2*k-2*i-2; j++)
                out+=space;
        out+=slash;
        for(let j=0; j<i;j++)
            out+=space;};
    out+=cr;};};
function abc(){
    k = document.getElementById('k').value;
    m = document.getElementById('m').value;
    n = document.getElementById('n').value;
    out ='<pre>\n';
    for(let i=0; i<n; i++){
        row1(k,m);
        row2(k,m);}
    out += '</pre>';      
    document.getElementById('out').innerHTML=out;}

教學影片

財金程式設計394期中考上機考與筆試題

留言

這個網誌中的熱門文章

崔甯甯建立JS函數用網頁BUTTON呼叫

崔甯甯期中考金融科技

崔甯甯20250102優質因子Factors ETF