7.1.3(分數拆分)

來源:互聯網
上載者:User

這個主要是靠你自己退出來範圍,要是盲目的算,你是一點思路都沒有的.,..

一般涉及到這種帶有不等號的題目,都會涉及到範圍的,,

誒誒誒誒,

今天就不寫了,,,想去看書了,,好想看沉思錄,,

剛才順便掃了一眼電視,,,那個叫什麼梨花嫂的...嗚嗚.

老天呀,為什麼年輕的時候你不讓我們在一起,老了的20年卻讓我們在一起,,,

誒誒誒, 感情這事呀..

#include <stdio.h>#include <string.h>#include <math.h>#include <iostream>#include <string>using namespace std;int x[11111];int y[11111];int main(){int k;cout << ceil(2.0000000) << endl;while (scanf("%d", &k) != EOF){int cnt = 0;for (int i = k + 1; i <= 2 * k; i++){double ans = (k * i) * 1.0/ (i - k) * 1.0;// 暈死了都,這個錯的我真的都不想活了呀,,,嗚嗚嗚//不是 判斷一個數是不是整數的錯了,,,原來是因為,double類型的除法錯了,,,暈死了//我就還是不長心,double類型的除法,是不能用整數做除數,被除數的,只能用double類型的. if ((int )ans == ans) {//printf("ans = %lf\n", ans);x[cnt] = (int )ans;y[cnt++] = i;}}cout << cnt << endl;for (int i = 0; i < cnt; i++){printf("1/%d = 1 / %d + 1 / %d\n", k, x[i], y[i]);}}system("pause");return 0;}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.