[英]My MPI fortran code gives different results for large integers
我是 MPI 編程的新手(剛接觸 3 天)。 我現在正在處理MPI_ALLREDUCE和MPI_REDUCE 。 下面的代碼取一個值n ,每個進程的任務是將變量mypartialsum加 1 n/num_procs次,其中num_procs是進程數。 歸約后, mypartialsum的值匯總到su ...
[英]My MPI fortran code gives different results for large integers
我是 MPI 編程的新手(剛接觸 3 天)。 我現在正在處理MPI_ALLREDUCE和MPI_REDUCE 。 下面的代碼取一個值n ,每個進程的任務是將變量mypartialsum加 1 n/num_procs次,其中num_procs是進程數。 歸約后, mypartialsum的值匯總到su ...
[英]C program to print array elements to terminal and txt file
我應該為此使用的 API 是 open()、write() 和 sprintf()。 如果您要發布對答案的回應,請不要推薦任何其他 API。 我的程序應該掃描 10 個元素,然后以相反的順序將這些元素打印到終端和一個 txt 文件。 數組的元素以相反的順序打印到終端非常好。 我卡住的區域是將其打印到 ...
[英]Simple C Coding Problem: Skipping Over Printf and Skipping User Input
https://onlinegdb.com/-9jZX-uU0 [鏈接] 我想讓第二行代碼讓用戶輸入華氏度而不是攝氏度兩次。 int main() 代碼是正確的,output 數字是正確的,但用戶沒有輸入華氏溫度。 我該如何解決? 在此處輸入圖像描述預期的是用戶輸入華氏度並且代碼繼續。 我不希望 ...
[英]C: Reading int values from a file only results in first line of the file being read
我正在 C 中編寫一個 function,它從給定文件中讀取 int 值,並在每次找到指定數字時加 1。 正在讀取的 My.txt 文件在每一行都有一個 int 后跟一個 float。 但是,我的問題是它只讀取第一行數字然后中斷循環。 導致問題的代碼部分是這樣的: 我的 current.txt 文件 ...
[英]How do I re-add decimal points to my Pandas column "Price" after converting it into an int?
我使用了代碼: 將我的dataframe列從 object 轉換為int ,這樣我就可以 plot 了。 這樣做刪除了所有符號並將它們變成空字符串,包括小數點,現在我的價格從 $22,000.00 變為 2200000 ($2,200,000)。 如何將小數放回它們所屬的位置,並盡可能將我的列保留 ...
[英]How can I concatenate the elements of a vector of integers to a string in C++?
我一直在嘗試將整數向量的每個元素放入一個字符串中。 我想通過將整數類型轉換為字符串來實現這一點,然后我將這些“小字符串”連接成一個大字符串,它將代表該特定向量的所有元素。 這可能看起來很傻,但如果你想制作一個返回類似矢量的 function 等,這真的很有用。 唯一的問題是我在第 13 行遇到錯誤 ...
[英]How to handle the bits in an array of bytes in python to derive integer, string and float values using hex conversion
從二進制文件中讀取輸入字節並將字節轉換為相應的十六進制值以獲得最終的 integer、字符串和浮點值。 嘗試將包含字節的輸入二進制文件讀入字節數組,然后處理數組值以導出 integer、字符串和浮點值。 ...
[英]Data type conversion problem for leetcode pratice "Moving Average from Data Stream"
當我運行 leetcode 問題““來自數據流的移動平均線””的代碼時。 我得到了一個與預期部分不同的 output: 這是我的代碼: 對代碼的要求是: 當我運行所提供示例的測試用例時,一切正常。 但是當我運行這個邊緣案例時,事情就不同了:["MovingAverage","next","nex ...
[英]Most pythonic way to split string into integers
我有一個字符串需要驗證它是否為“#-#”形式,其中#s 應該是無符號整數。 將其拆分為兩個整數 lo 和 hi 的最 pythonic 方法是什么,可能包括 lo < hi 的類型檢查/驗證、無符號整數等? 我考慮過各種解決方案,但我有不同的標准,它必須確保 # 和 # 是無符號整數,中間只有 ...
[英]Why is the Number() function not working when I use it this way?
function sumDigits(num) { // your code here let nums = num.toString(); let sum = 0; for(let i = 0;i<nums.length;i++){ Number(nums[i]); console.log ...
[英]Function needs to be made before calling it, but variable has to be assigned before referenced
獲取年齡 function 需要 y 在這個程序中,我如何修復錯誤: (文件為maintmp.py) ...
[英]How to grab multiple rows excluding hidden ones and move them in Excel VBA
我正在嘗試將盡可能多的行從一張紙復制並粘貼到另一張紙上,然后在使用循環移動該行后將其刪除; 但我需要能夠跳過隱藏的行。 現在我的代碼只適用於我選擇的第一行——它將完全移動它,包括刪除它並隱藏隱藏的行。 我添加了 m integer,因為在添加它之前,僅使用 k integer(並在每個循環中將其放 ...
[英]C++ How to convert an unsigned integer to a hex string without a thousands separator
為了存儲按鈕文本的顏色,我將變量uint32_t textColor設置為值 0xF5CE52 (0d16109138)。 現在我需要將此 textColor 值作為十六進制值插入到字符串中。 但是,當我嘗試通過字符串流將 textColor 轉換為十六進制字符串時,似乎在十六進制字符串中插入了千位 ...
[英]Make updated Int stay the same in a new struct
我有一個將 + 1 添加到 Int 的按鈕。 我希望能夠在另一個結構中訪問 Int 的值。 現在我可以訪問 Int,但它從零開始,不顯示按下前一個結構中的按鈕后添加的 + 1 的數量。 有沒有辦法“記住”添加的整數? ...
[英]Problem in program to input a 3 digit number and check which digits are even and replace it with odd digits
輸入 3 位數編號時出現問題,但沒有得到任何結果。 輸入 123 后,當檢測到 2 為偶數時,如果用戶輸入 7,則應顯示 173。但程序立即結束。 這可能是最后一個 0 檢查 if-block 的問題。 但刪除它也無濟於事。 提前致謝! ...
[英]How to swap first and last nibbles in given integer [32 bits]
認為:No = 77 77 in binary [32 bits] : 0000 0000 0000 0000 0000 0000 0100 1101 我必須交換第一個和最后一個半字節:i.e : 1101 0000 0000 0000 0000 0000 0 ...
[英]Negative input crashes program
我有以下 function: 一些功能是自制的(strlen = ft_strlen 等)。 問題:如果我為“開始”傳遞 -1,我的程序會出現段錯誤,因為它被轉換為 4.294.967.295。 所以它在傳入時崩潰,我的 function 身體甚至沒有執行,使所有保護措施都無用。 更奇怪的是,如果我 ...
[英]What is the point of format specifier in C?
如果我們已經在 printf 之前設置了變量類型,那么 C 中的格式說明符有什么意義呢? 例如: 就像,它已經說明了 a 是什么,它是 integer(int)。 那么添加 %d 以指定它是 integer 有什么意義呢? ...
[英]Delphi - from Integer to Byte type (negative number conversion)
我測試了一些代碼: 我希望在數字 10 中的變量中看到結果(因為這是 integer 類型的低字節)。 但結果是 B => 246。 從邏輯上講,我理解 246 = 256 - 10,但我不明白為什么會這樣? ...
[英]How to read an integer value in char type?
我想用 scanf() 做一個小實驗。 我想從用戶那里讀取一個小的 (<=255) integer 並將其存儲在 char 類型中。 我做了: 它有效,但我想讓編譯器滿意而不是收到此警告: 任何的想法? ...