在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/ C問答
遺莣 回答

c的字符串數(shù)組需要在末尾有'0'標志字符串結(jié)束, 很多時候'0'會自動添加. 但是 char[] str = {'a', 'b', 'c'};不會這樣, 所以你需要char[] str = {'a', 'b', 'c', '\0};

你漏了'0', 所以scanf沒有讀到'0', 會一直讀下去, windows下會輸出燙, 至于為什么, 讀這里

https://www.zhihu.com/questio...

https://zhuanlan.zhihu.com/p/...

爆棧的相關(guān)帖子:

https://stackoverflow.com/que...

https://stackoverflow.com/que...

https://stackoverflow.com/que...


影魅 回答

router.get('/hello/:name', async (ctx, next) => {

....
ctx.response.body = result //數(shù)據(jù)結(jié)果;

});

糖豆豆 回答

使用 ES5 內(nèi)置數(shù)組函數(shù) + 箭頭函數(shù)隱藏 for 循環(huán)細節(jié)

packageInfoList.forEach(package => {
    var newPackage = ConfigData.getGoods(true, package.id);
    package.packageTag.forEach(tag => {
        var newTag = newPackage.packageTag.find(t => t.id === tag.id);
        if(!newTag) return;
        tag.goods.forEach(goods => {
            var newGoods = newTag.goods.find(g => g.id === goods.id);
            if(!newGoods) return;
            var flag = updateGoodAttr(goods, newGoods);
        });
    });
});

updateGoodAttr = (goods, newGoods) => {
    goods.attr.forEach(attr => {
        var newAttr = newGoods.attr.find(a => a.id === attr.id)
        attr.option.filter(taste => !!taste.select).foreach(taste => {
            var newTasteOption = newAttr.option.find(t => t.id === taste.id);
            if(newTasteOption) {
                newTasteOption.select = taste.select;
            }
        });
    });
}

提取重復(fù)的數(shù)組比對邏輯

已經(jīng)省去里很多迭代的下角標處理里,但是代碼還是很啰嗦,頻繁重復(fù)對兩個數(shù)組進行元素比較。干脆把這個邏輯提取出來:

var match = (arr1, arr2, identifier, process) => arr1.forEach(item1 => 
    arr2.forEach(item2 => identifier(item1) === identifier(item2) && process(item1, item2))
);

傳入兩個數(shù)組,對數(shù)組元素的每個元素使用 identifier 獲取 id,如果比較成功,則調(diào)用 process 函數(shù)處理這兩個元素。例子中 identifier 都一樣,即 item => item.id.

var ID = item => item.id;

var processPackage = (p1, p2) => match(p1.packageTag, p2.packageTag, ID, processTag);

var processTag = (tag1, tag2) => match(tag1.goods, tag2.goods, ID, processGoods);

var processGoods = (goods1, goods2) => match(goods1,attr, goods2.attr, ID, processAttr);

var processAttr = (attr1, attr2) => match(attr1.options.filter(taste => !!taste.select), attr2.options, ID, processTaste);

var processTaste = (taste1, taste2) => taste2.select = taste1.select


var packageInfoList = [...], configPackageList = [...];

match(packageInfoList, configPackageList, ID , processPackage);

消除重復(fù)調(diào)用

目前代碼中還存在重復(fù)地調(diào)用 match 函數(shù),調(diào)用邏輯相似而重復(fù),如果能把這塊抽出來就好了。我們再提取一個函數(shù),用來構(gòu)造 processXXXprocessAttr比較特殊,對兩邊取子屬性的邏輯不一樣,所以提取的這個函數(shù)需要考慮 processAttr 的需求。

var subProcess = ([s1, s2], id, process) => (i1, i2) => match(s1(i1), s2(i2), id, process)

var fixSelector = f => Array.isArray(f) ? f : [f, f]
var processTaste = (taste1, taste2) => taste2.select = taste1.select
var processAttr = subProcess(
    fixSelector([item => item.options.filter(taste => !!taste.select), item => item.options]), 
    ID,
    processTaste
)
var processGoods = subProcess(fixSelector(item => item.attr), ID, processAttr)
var processTag = subProcess(fixSelector(item => item.goods), ID, processGoods)
var processPackage = subProcess(fixSelector(item => item.tag), ID, processTag)


var ID = item => item.id
match(
    packageInfoList,
    configPackageList,
    ID,
    processPackage
);

最后一步調(diào)用其實等價于:

subProcess(fixSelector([() => packageInfoList, () => configPackageList], ID, 
    subProcess( fixSelector(package => package.tag), ID
        subProcess( fixSelector(tag => tag.goods), ID,
            subProcess( fixSelector(goods => goods.attr), ID
                subProcess( fixSelector([attr => attr.options.filter(taste => !!taste.select), attr => attr.options]), ID
                    processTaste
                )
            )   
        )          
    )
)()

把掉套函數(shù)調(diào)用拉平試試?試想如下代碼:

f(a, f(b, f(c, f(d, e)))))

// 等價于

[a,b,c,d,e].reduceRight((prev, item) => f(item, prev))

于是有:

var match = (arr1, arr2, identifier, process) => arr1.forEach(item1 => 
    arr2.forEach(item2 => identifier(item1) === identifier(item2) && process(item1, item2))
)
var subProcess = ([s1, s2], id, process) => (i1, i2) => match(s1(i1), s2(i2), id, process)
// 為了傳遞 selector 的時候可以單獨給一個函數(shù)
var fixSelector = f => Array.isArray(f) ? f : [f, f]
var reducer = (prev, [selector, identifier]) => subProcess(fixSelector(selector), identifier, prev)
var process = (...items) => items.reduceRight(reducer)()


// 調(diào)用
process(
    [ [() => packageInfoList, () => configPackageList], ID], // 初始數(shù)據(jù)
    [ package => package.tag, ID], // 根據(jù)上面一項的元素,返回需要繼續(xù)比對的下一層數(shù)據(jù)
    [ tag => tag.goods, ID], // 把ID當參數(shù)在每一層傳進來是為了支持不同層取 ID 的方式不同
    [ goods => goods.attr, ID], // 再深也不怕,無非多一個參數(shù)
    // 支持兩邊不同的取值方法
    [ [attr => attr.options.filter(taste => !!taste.select), attr => attr.options], ID], 
    // 最后一個函數(shù)就是你處理深處數(shù)據(jù)的地方啦
    (taste1, taste2) => taste2.select = taste1.select 
)

雖然調(diào)用的時候挺漂亮的,但是有點繞。。。

心癌 回答

view不論設(shè)置成什么形式都可以的。但detail形式時,鼠標移動到subitem上時無效,必須要移到最前面一列才行。

還有這個屬性 showitemtooltips=true

賤人曾 回答

強制設(shè)置item的frame試試,例如修改到60x60

[[UIBarButtonItem alloc]initWithCustomView:_xxxButton]; //沒記錯應(yīng)該是這樣寫
[_xxxButton setFrame:CGRectMake(0,0,60,60)];

ps 導(dǎo)航條item最后顯示的origin與設(shè)置的origin沒有直接聯(lián)系,但是size會有關(guān)聯(lián)

冷眸 回答

要保持上次閱讀內(nèi)容的話,你什么都不用處理,只需要實現(xiàn)下拉刷新,上拉加載就行了。

我以為 回答

這不小學(xué)問題么,不知道你想問什么,或者你覺得難的地方是什么。

安于心 回答

這個問題已經(jīng)有人在 Swoole 提過 issue。

可能是高版本gcc+低版本內(nèi)核導(dǎo)致的,libc中有signalfd的函數(shù),但是linux內(nèi)核不支持??梢孕薷腗akefile去掉HAVE_SIGNALFD或升級Linux內(nèi)核。

具體可以去看下 這個問題

抱緊我 回答

我是存在localstorage里,然后進入最外層的路由時判斷:

let routes = [{
    path: '/login',
    component: Login,
    name: 'login'
},{
    path: '/admin',
    component: Admin,
    beforeEnter: (to, from, next) => {
        if(!localStorage.ACCOUNT || localStorage.ACCOUNT == ''){
            next({
                name: 'login'
            })
        }else{
            next()
        }
    }
}]
無標題 回答

你學(xué)擰巴了。MBR分區(qū)表項只能容納4個主分區(qū)或者擴展分區(qū)(至少有一個主分區(qū),擴展分區(qū)最多有一個,比如可以是4主或者是3主+1擴這樣,當然windows比較傳統(tǒng)的思路還是1主1擴),擴展分區(qū)的下級才是邏輯分區(qū),我記得上限好像是64個,但是這個上限得看操作系統(tǒng),比如你在windows下把26個字母都分出去了,那么剩下的你就用不了了。

我以為 回答
  1. domainapi.qna.com,只有api.qna.com主機里的頁面可以訪問這個cookie;
  2. domainapi.hotel.com,只有api.hotel.com主機里的頁面可以訪問這個cookie;
  3. 只能設(shè)置hotel.comcookie,不能設(shè)置qna.comcookie。因為你的程序不被允許設(shè)置百度或者工商銀行的cookie,否則你可以任意欺詐用戶。
  4. 如果你需要在發(fā)送ajax請求時附加相應(yīng)該主機的cookie,需要加上withCredential參數(shù)。
司令 回答

C語言標準中的邏輯位移和算術(shù)位移

在 C 語言中,涉及位移的運算符有2個,>>表示右移,<<則表示左移。
而匯編指令中,SHLSHR表示邏輯左移和邏輯右移,SARSAL表示算術(shù)左移和算術(shù)右移。
其中,邏輯左移和算術(shù)左移都是寄存器二進制位整體向左移動,并在右邊補0。
而右移則不同,邏輯右移是整體向右移,并在左邊補0,而算術(shù)右移則是根據(jù)原符號位的值補與其相同的值。

那么如何在 C 語言中分別實現(xiàn)邏輯和算術(shù)位移呢?根據(jù) C 標準,如果在位移運算符左邊的變量是有符號數(shù),如int, char, short等,編譯產(chǎn)生的匯編指令是算術(shù)位移指令,如果該變量是無符號數(shù),如unsigned int, unsigned char等,編譯產(chǎn)生的匯編指令則是邏輯位移指令。

移位指令

SAL(shift arithmetic left) 算術(shù)左移
格式:SAL, OPR, CNT
含義: 算術(shù)左移SAL把目的操作數(shù)的低位向高位移,空出的低位補0.(指將要移位的操作數(shù)換成二進制表示方法,如62H01100010B,移位時只是尋常理解中的將這些二進制位逐個向左或向右移,移走的數(shù)根據(jù)操作符決定舍棄或者放入空出的位置,空出的位置根據(jù)操作符決定補0或者放入移走的數(shù))。

由上述可以知道,底層執(zhí)行10 << 31的時候,超出長度部分會被舍棄,然后在原來的空位上補0

青黛色 回答

c的所有全局變量都在同一個命名空間中,所以全局變量名字不能重復(fù);你可以試試把函數(shù)定義為內(nèi)部的

愛礙唉 回答

clipboard.png

GCC表示沒有這個問題

猜測是你IDE的問題,不知道你什么IDE,估計是啟用了默認庫文件的選項

題目的代碼格式難以入目

孤影 回答

c++ std庫里有個類bitset, 是專門做這個事的

這里有源碼, 如果你一定要c, 可以看看這個
https://gcc.gnu.org/onlinedoc...

重點是left_shift和right_shift

字符串和bitset的轉(zhuǎn)換可以看這里

http://blog.csdn.net/magicyan...

朕略萌 回答

老哥 放張圖阿

6 plus DPR 是3 小的iphone dpr是2,所以肯定不行

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">不行

要js動態(tài)設(shè)定縮放比例

http://lustforlife.cn/2017/11...

這也是一種間接的默認標準吧,太少了不行(太少有可能嘗試出正確數(shù)),太多了也不行,4~6為最好,6位最佳,你看支付寶支付、微信支付6位,銀行卡密碼6位

離魂曲 回答

node-iconv

官網(wǎng)實例

// convert from UTF-8 to ISO-8859-1
var Buffer = require('buffer').Buffer;
var Iconv  = require('iconv').Iconv;
var assert = require('assert');

var iconv = new Iconv('UTF-8', 'ISO-8859-1');
var buffer = iconv.convert('Hello, world!');
var buffer2 = iconv.convert(new Buffer('Hello, world!'));
assert.equals(buffer.inspect(), buffer2.inspect());
// do something useful with the buffers
影魅 回答

1.如果你的title類和list類可能出現(xiàn)復(fù)用也就是其他元素也可能用到這兩個類的情況下那肯定是分開寫的
2.如果只是要定義list的樣式,那么一個類就夠了