摘要: for循环: 1 for (int val = 0;val <= 100;++val){ 2 sum += val; 3 } for语句包含两部分:循环头和循环头。循环头控制循环体的执行次数,它由三部分组成:一个初始化语句(init-statement)、一个循环条件(condition)以及一个表 阅读全文
posted @ 2018-08-22 20:53 archerzon 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 编写程序:提示用户输入两个整数,打印出这两个整数所指定的范围内的所有整数的和。 1 #include <iostream> 2 #include <algorithm> 3 int main() 4 { 5 std::cout<<"Enter two numbers:"<<std::endl; 6 阅读全文
posted @ 2018-08-22 15:14 archerzon 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 注释分为两类:单行注释和界定符对注释 单行注释:// 1 #include <iostream> 2 //简单函数,求和 3 int main() 4 { 5 std::cout<<"**"; 6 system("pause"); 7 return 0; 8 } 界定符对注释:以/*开头,*/结尾。 阅读全文
posted @ 2018-08-22 13:07 archerzon 阅读(177) 评论(0) 推荐(0) 编辑
摘要: iostream库包含两个基础类型 istream 和 ostream ,分别表示输入流和输出流。 标准库定义了4个IO对象: std::cin标准输入 std::cout标准输出 std::cerr标准错误,用来输出警告和错误信息 std::clog用来输出程序运行时的一般性信息 加法: 1 #i 阅读全文
posted @ 2018-08-22 12:57 archerzon 阅读(214) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h>:定义输入/输出函数 #include <stdlib.h>:定义杂项函数及内存分配函数 1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 printf("hello world!\n\ 阅读全文
posted @ 2018-08-22 11:48 archerzon 阅读(97) 评论(0) 推荐(0) 编辑