欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > cs106x-day1

cs106x-day1

2025/2/8 7:01:00 来源:https://blog.csdn.net/jm999999999/article/details/145504354  浏览:    关键词:cs106x-day1

开始打卡cs106x(Autumn 2017)-lecture1

cs106x这门课的介绍: 主要通过 C++ 语言让学生在实际的编程作业里培养通过编程抽象解决实际问题的能力,同时也会涉及一些简单的数据结构和算法的知识,但总体来说没有一门专门的数据结构课那么系统。

1、CodeStepByStep-helloWorld

Write a complete C++ program with a main function that prints the following console output:

Hello, world!

解答

#include <iostream>
#include "console.h"using namespace std;int main() {cout << "Hello, world!" << endl;return 0;
}

2、CodeStepByStep-stanfordVsCal

Write a complete C++ program with a main function that computes who won the Stanford-Berkeley football game. The program should ask the user for the two scores. You may assume that the user enters valid non-negative integers. Below is an example dialogue (user input is shown like this):

Stanford: How many points did they score? 87
Cal: How many points did they score? 3
Stanford won!

解答

#include <iostream>
#include "console.h"
#include "simpio.h"using namespace std;int main()
{int stanford = getInteger("Stanford: How many points did they score?");int cal = getInteger("Cal: How many points did they score?");if (stanford >= cal) {cout << "Stanford won!" << endl;} else {cout << "Cal won!" << endl;}return 0;
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com