合肥生活安徽新聞合肥交通合肥房產生活服務合肥教育合肥招聘合肥旅游文化藝術合肥美食合肥地圖合肥社保合肥醫院企業服務合肥法律

        CSCI1540代寫、代做C++設計編程
        CSCI1540代寫、代做C++設計編程

        時間:2024-10-16  來源:合肥網hfw.cc  作者:hfw.cc 我要糾錯



        CSCI1540 Fundamental Computing with C++, Fall 2024/25 
        Department of Computer Science and Engineering, The Chinese University of Hong Kong 
        Copyright © 2024 CSE, CUHK Page 1 of 2 
        Due: 23:59, Thu 17 Oct 2024 File name: kaprekar.cpp Full marks: 100 
        Introduction 
        The objective of this assignment is to master the use of selective and nested repetitive control flow. 
        You will write nested loops to look for Kaprekar numbers. 
        A Kaprekar number is a positive integer    if the digits of the square   
        2
         can be split into two parts 
        that add up to   , where the part formed from the low-order (rightmost) digits of   
        2
         must be nonzero
         (although leading zeroes are allowed in the part). For example, 45 is a Kaprekar number, 
        because 45
        2 = 2025 can be split into two parts 20 and 25, with 20 + 25 = 45. As another example, 
        999 is also a Kaprekar number, because 999
        2 = 998001 and 998 + 001 = 999. (Note the loworder
         part 001 includes leading zeroes.) However, 31 is not a Kaprekar number, because all three 
        possible splits of 31
        2 = 961 are no good (96 + 1 ≠ 31, 9 + 61 ≠ 31, and 0 + 961 ≠ 31). 
        Program Specification 
        The program shall ask for two user inputs    and   . They are assumed to be always integers. You are 
        required to use the data type long long instead of int for all integer variables in this assignment, 
        because a square can easily go overflow with (that is, larger than the upper bound of) the int type. 
        1. The program first prompts the user to enter an integer   . When    is not positive, you shall 
        display a warning message and ask for another input, until    is positive. Your program shall look 
        for Kaprekar number(s) greater than or equal to   . 
        2. Then prompt the user to enter how many Kaprekar numbers the user is looking for. When this 
        input    is not positive, display a warning message and ask for another input, until    is positive. 
        3. After validating inputs    and   , repeatedly test   ,    + 1,    + 2,    + 3, … to check whether it is a 
        Kaprekar number. If so, print out the square and the split of the two parts. (See the upcoming 
        Sample Runs section for the printing format.) Repeat these checks until    Kaprekar numbers are 
        found and printed. Then program execution ends. 
        ➢ To check whether a number    is a Kaprekar number, you progressively check all possible 
        splits of   
        2
        . E.g., let    = 345 and hence   
        2 = 11**25. The first split to check is 11**2 and 
        5; the next split is 11** and 25; the next split is 119 and 025; and so on. 
        Note: In this assignment, you are not allowed to: (1) use any functions in the <cmath> library, (2) 
        write any functions other than main(), and (3) use any arrays/vectors (which are not yet taught). 
        Sample Runs 
        In the following sample runs, the blue text is user input and the other text is the program printout. 
        You can try the provided sample program for other input. Your program output should be exactly the 
        same as the sample program (same text, symbols, letter case, spacings, etc.). Note that there is a 
        space after the ‘:’ and ‘?’ in the program printout. CSCI1540 Fundamental Computing with C++, Fall 2024/25 
        Department of Computer Science and Engineering, The Chinese University of Hong Kong 
        Copyright © 2024 CSE, CUHK Page 2 of 2 
        Enter an integer: 40↵ 
        How many Kaprekar numbers? 3↵ 
        45^2 = 2025 
        20 + 25 = 45 
        55^2 = 3025 
        30 + 25 = 55 
        99^2 = 9801 
        98 + 1 = 99 
         
        Enter an integer: -23↵ 
        Input must be +ve! Enter again. 
        Enter an integer: -1↵ 
        Input must be +ve! Enter again. 
        Enter an integer: 0↵ 
        Input must be +ve! Enter again. 
        Enter an integer: 200↵ 
        How many Kaprekar numbers? 0↵ 
        Input must be +ve! Enter again. 
        How many Kaprekar numbers? 0↵ 
        Input must be +ve! Enter again. 
        How many Kaprekar numbers? -777↵ 
        Input must be +ve! Enter again. 
        How many Kaprekar numbers? 5↵ 
        297^2 = 88209 
        88 + 209 = 297 
        703^2 = 494209 
        494 + 209 = 703 
        999^2 = 998001 
        998 + 1 = 999 
        2223^2 = 4941729 
        494 + 1729 = 2223 
        2728^2 = 7441984 
        744 + 1984 = 2728 
        Submission and Marking 
        • Your program file name shall be kaprekar.cpp. Submit the file in Blackboard 
        (https://blackboard.cuhk.edu.hk/). 
        • Insert your name, student ID, and e-mail as comments at the beginning of your source file. 
        • You can submit your assignment multiple times. Only the latest submission counts. 
        • Your program should be free of compilation errors and warnings. 
        • Your program should include suitable comments as documentation. 
        • Do NOT share your work to others and do NOT plagiarize. Both senders and plagiarists shall be 
        penalized. 

        請加QQ:99515681  郵箱:99515681@qq.com   WX:codinghelp






         

        掃一掃在手機打開當前頁
      1. 上一篇:代寫FIT2107、代做Python設計編程
      2. 下一篇:FIT2102代做、代寫Java/Python設計程序
      3. 無相關信息
        合肥生活資訊

        合肥圖文信息
        出評 開團工具
        出評 開團工具
        挖掘機濾芯提升發動機性能
        挖掘機濾芯提升發動機性能
        戴納斯帝壁掛爐全國售后服務電話24小時官網400(全國服務熱線)
        戴納斯帝壁掛爐全國售后服務電話24小時官網
        菲斯曼壁掛爐全國統一400售后維修服務電話24小時服務熱線
        菲斯曼壁掛爐全國統一400售后維修服務電話2
        美的熱水器售后服務技術咨詢電話全國24小時客服熱線
        美的熱水器售后服務技術咨詢電話全國24小時
        海信羅馬假日洗衣機亮相AWE  復古美學與現代科技完美結合
        海信羅馬假日洗衣機亮相AWE 復古美學與現代
        合肥機場巴士4號線
        合肥機場巴士4號線
        合肥機場巴士3號線
        合肥機場巴士3號線
      4. 上海廠房出租 短信驗證碼 酒店vi設計

        主站蜘蛛池模板: 国产Av一区二区精品久久| 免费萌白酱国产一区二区三区| 日本韩国一区二区三区| jizz免费一区二区三区| 麻豆国产一区二区在线观看| 免费人人潮人人爽一区二区 | 三上悠亚国产精品一区| 国产精品一级香蕉一区| 国产在线无码视频一区二区三区| 国产麻豆精品一区二区三区| 中文字幕一区二区三区有限公司| 国产一区二区在线| 国产大秀视频在线一区二区| 久久精品人妻一区二区三区 | 精品人妻少妇一区二区三区不卡| 日韩精品无码一区二区三区AV| 北岛玲在线一区二区| 精品无码国产AV一区二区三区| 国产香蕉一区二区三区在线视频| 无码人妻精品一区二区三| 美女一区二区三区| 国产人妖视频一区二区| 久久亚洲一区二区| 狠狠色综合一区二区| 在线观看一区二区三区视频| 亚洲欧美国产国产一区二区三区| 国产精品综合AV一区二区国产馆| 亚洲一区二区影视| 国产免费私拍一区二区三区| 黑人一区二区三区中文字幕| 大伊香蕉精品一区视频在线| 中文字幕一区二区三区乱码| 日韩欧国产精品一区综合无码| 一区二区三区在线免费看| 爆乳无码AV一区二区三区| 欧洲精品码一区二区三区免费看 | AV天堂午夜精品一区| 精品一区二区三区东京热| 色多多免费视频观看区一区| 国产福利视频一区二区| 亚洲AV日韩综合一区尤物|