一、说明
写这个博客是为了记录学习清华大学-c++课程-郑莉教授版本过程中的一些我自己认为关键的知识点,方便自己日后迅速复习和查阅。本篇主要包含该课程第一章和第二章的一些笔记。如果您在阅读过程中有任何意见和建议,请批评指正,感谢。
二、内容
1.基本知识点
单行注释://
多行注释:/*...*/
常量、变量与自定义类型(结构体类型)定义、条件语句、循环语句、关键词break和continue的基本语法:
// ex1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//const && sizeof
const float pi = 3.1415;
cout << sizeof(pi) << endl;
//setw() and setprecision(),included in <iomanip>
int a = 1, b = 5,c;
c = a > b ? a : b;
double d = 2.4;
cout << setprecision(2) << d << endl;
cout << setw(5)<<c << endl;
//switch case
switch (c) {
case 1:cout << "a>b" << endl;
case 5:cout << "a<=b" <&l