楼主: zhaosl
1783 7

C++ Without Fear, 3rd Edition [推广有奖]

已卖:25285份资源

学术权威

4%

还不是VIP/贵宾

-

威望
0
论坛币
37646209 个
通用积分
554.7190
学术水平
80 点
热心指数
92 点
信用等级
73 点
经验
83705 点
帖子
2785
精华
2
在线时间
6998 小时
注册时间
2005-4-15
最后登录
2024-8-20

楼主
zhaosl 发表于 2016-10-3 10:50:10 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
  • Author:Brian Overland
  • Isbn:0134314301
  • Year:2015
  • Pages:619
  • Language:English
  • File size:23.39 MB
  • File format:PDF
  • Category:C & C++
  • Book Description:
  • Learning C++ Doesn’t Have to Be Difficult!








本帖是回复如下帖子:


https://bbs.pinggu.org/thread-4858043-1-1.html
求:C++ Without Fear, 3rd Edition





二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:without Edition editio dition withou 3rd Ed Without Fear

C Without Fear(3rd).pdf
下载链接: https://bbs.pinggu.org/a-2110493.html

18.46 MB

需要: 2 个论坛币  [购买]

C++ Without Fear, 3rd Ed

本帖被以下文库推荐

阿里云盘注册就有1000G,点此链接领取福利:
https://pages.aliyundrive.com/mobile-page/web/beinvited.html?code=ca953c2

沙发
hjtoh(未真实交易用户) 发表于 2016-10-3 12:06:29 来自手机
zhaosl 发表于 2016-10-3 10:50
  • Author:Brian Overland
  • Isbn:0134314301
  • Year:2015
  • 谢谢分享

    藤椅
    fin9845cl(真实交易用户) 发表于 2016-10-9 16:48:52
    thanks for sharing。。。。

    板凳
    ReneeBK(未真实交易用户) 发表于 2017-2-1 11:33:15
    1. Example 4.1. Printing 1 to N with “for”

    2. Now we’ll apply the for statement in a complete program. This example does the same thing as Example 2.2 on page 43: It prints all the numbers from 1 to n. But this version is more compact.
    3. count2.cpp
    4. Click here to view code image

    5. #include <iostream>
    6. using namespace std;

    7. int main()
    8. {
    9.     int  n = 0;
    10.     int  i = 0;   // Loop counter in "for" statement.

    11.     // Get num from the keyboard and initialize i.

    12.     cout << "Enter a number and press ENTER: ";
    13.     cin >> n;
    14.     for (i = 1; i <= n; ++i){   // For i = 1 to n
    15.         cout << i << " ";       //    Print i.
    16.     }
    17.     return 0;
    18. }
    复制代码

    报纸
    ReneeBK(未真实交易用户) 发表于 2017-2-1 11:34:52
    1. #include <iostream>
    2. #include <cmath>

    3. using namespace std;

    4. int main()
    5. {
    6.     int  n = 0;   // Number to test for prime-ness
    7.     bool is_prime = true; // Boolean flag; assume true
    8.                           //   until proven otherwise

    9.     // Get a number from the keyboard.

    10.     cout << "Enter a number and press ENTER: ";
    11.     cin >> n;

    12.     // Test for prime by checking for divisibility
    13.     //  by all whole numbers from 2 to sqrt(n).

    14.     for (int i = 2; i <= sqrt(n); ++i) {
    15.         if (n % i == 0) {
    16.             is_prime = false;
    17.         }
    18.     }

    19.     // Print results

    20.     if (is_prime) {
    21.         cout << "Number is prime." << endl;
    22.     } else {
    23.         cout << "Number is not prime." << endl;
    24.     }
    25.     return 0;
    26. }
    复制代码

    地板
    ReneeBK(未真实交易用户) 发表于 2017-2-1 11:35:50
    Example 4.2. Prime-Number Test with “for”
    1. #include <iostream>
    2. #include <cmath>

    3. using namespace std;

    4. int main()
    5. {
    6.     int  n = 0;   // Number to test for prime-ness
    7.     bool is_prime = true; // Boolean flag; assume true
    8.                           //   until proven otherwise

    9.     // Get a number from the keyboard.

    10.     cout << "Enter a number and press ENTER: ";
    11.     cin >> n;

    12.     // Test for prime by checking for divisibility
    13.     //  by all whole numbers from 2 to sqrt(n).

    14.     for (int i = 2; i <= sqrt(n); ++i) {
    15.         if (n % i == 0) {
    16.             is_prime = false;
    17.         }
    18.     }

    19.     // Print results

    20.     if (is_prime) {
    21.         cout << "Number is prime." << endl;
    22.     } else {
    23.         cout << "Number is not prime." << endl;
    24.     }
    25.     return 0;
    26. }
    复制代码


    7
    ReneeBK(未真实交易用户) 发表于 2017-2-1 11:38:47
    1. Example 6.1. Print Out Elements

    2. Let’s start by looking at one of the simplest programs possible that uses an array. The rest of the chapter gets into more interesting programming challenges.
    3. print_arr.cpp
    4. Click here to view code image

    5. #include <iostream>
    6. using namespace std;

    7. int main()
    8. {
    9.     double scores[5] = {0.5, 1.5, 2.5, 3.5, 4.5};

    10.     for(int i = 0; i < 5; ++i) {
    11.         cout << scores[i] << "  ";
    12.     }
    13.     return 0;
    14. }
    复制代码

    8
    ReneeBK(未真实交易用户) 发表于 2017-2-1 11:47:04

    Example 6.2. How Random Is Random?

    1. #include <iostream>
    2. #include <cstdlib>
    3. #include <ctime>

    4. using namespace std;

    5. int rand_0toN1(int n);
    6. int hits[10];

    7. int main()
    8. {
    9.     int n = 0;  // Number of trials; prompt from user
    10.     int r = 0;  // Holds a random value

    11.     srand(time(nullptr));   // Set seed for randomizing.

    12.     cout << "Enter how many trials and press ENTER: ";
    13.     cin >> n;

    14.     // Run n trials. For each trial, get a num 0 to 9
    15.     //  and then increment the corresponding element
    16.     //  in the hits array.

    17.     for (int i = 0; i < n; ++i) {
    18.         r = rand_0toN1(10);
    19.         ++hits[r];
    20.     }

    21.     // Print all elements in the hits array, along
    22.     //  with ratio of hits to EXPECTED hits (n / 10).

    23.     for (int i = 0; i < 10; ++i) {
    24.        cout << i << ": " << hits[i] << " Accuracy: ";
    25.        double results = hits[i];
    26.        cout << results / (n / 10.0) << endl;
    27.     }
    28.     return 0;
    29. }

    30. // Random 0-to-N1 Function.
    31. // Generate a random integer from 0 to N-1.
    32. //
    33. int rand_0toN1(int n) {
    34.     return rand() % n;
    35. }
    复制代码

    您需要登录后才可以回帖 登录 | 我要注册

    本版微信群
    jg-xs1
    拉您进交流群
    GMT+8, 2025-12-27 08:59