【C++笔记】第一章 快速入门.cc
来源:互联网 发布:linux服务器防御 编辑:程序博客网 时间:2024/06/05 11:12
int main() {return 0;}cin cout cerr clog#include <iostream>int main() {std::cout << "Enter two numbers:" << std::endl;int v1, v2;std::cin >> v1 >> v2;std::cout << "The sum of " << v1 << " and " << v2 << " is " << v1 + v2 << std::endl;return 0;}#include <iostream>int main() {std::count << "Hello World!" << std::endl;return 0;}#include <iostream>int main() {std::cout << "Enter two numbers:" << std::endl;int v1, v2;std::cin >> v1 >> v2;std::cout << "The product of " << v1 << " and " << v2 << " is " << v1 * v2 << std::endl;return 0;}#include <iostream>int main() {std::cout << "Enter two numbers:" << std::endl;int v1, v2;std::cin >> v1 >> v2;std::cout << "The sum of";std::cout << v1;std::cout << " and ";std::cout << v2;std::cout << " is ";std::cout << v1 + v2;std::endl;return 0;}// 不合法的例子std::cout << "The sum of " << v1; << " and " << v2; << " is " << v1 + v2 << std:: endl;#include <iostream>/* Simple main function: Read two numbers and write their sum */int main () {// prompt user to enter two numbersstd::cout << "Enter two numbers:" << std::endl;int v1, v2; // uninitializedstd::cin >> v1 >> v2; // read inputreturn 0;}// 注释不可嵌套#include <iostream>/* * comemt pairs /* */ cannot nest. * "cannot nest" is considered source code, * as is the rest of the program */int main () {return 0;}std::cout << "/*" << std::endl;std::cout << "*/" << std::endl;std::cout << /* "*/" */ << std::endl; #include <iostream>int main() {int sum = 0, val = 1;while(val <= 10) {sum += val;val++;}std::cout << " Sum of 1 to 10 inclusive is " << sum << std::endl;return 0;}#include <iostream>int main() {int sum = 0;for( int val = 0; i <= 10; ++val) {sum += val;}std::cout << " Sum of 1 to 10 inclusive is " << sum << std::endl;return 0;}#include <iostream>int main() {int sum = 0;for(int i = -100; i <=100 ;++i) {sum += i;}// sum = 0;return 0;}#include <iostream>int main() {int sum = 0;for(int i = 50; i <= 100; i++) {sum += i;}return 0;}#include <iostream>int main() {int sum = 0, val = 50;while(val <= 100) {sum += val;val++;}}#include <iostream>int main() {int val = 10;while(val >=0 ) {std::cout << " val = " << val << std::endl;val--;}return 0;}#include <iostream>int main() {for(int i = 10; i >=0; i--) {std::count << " i = " << i << std::endl;}return 0;}#include <iostream>int main() {std::cout << "Enter two numbers:" << std::endl;int v1, v2;std::cin >> v1 >> v2;int lower, upper;if (v1 <= v2) {lower = v1;upper = v2;} else {lower = v2;upper = v1;}int sum = 0;for (int val = lower; i <= upper; val++) {sum += val;}std::cout << "Sum of " << lower << " to " << upper << " inclusive is " << sum << std::endl;return 0;}#include <iostream>int main() {std::count << "Enter two numbers:" << std::endl;int v1, v2;std::cin >> v1 >> v2;if (v1 >= v2) {std::cout << "The bigger number is " << v1 << std::endl; } else {std::cout << "The bigger number is " << v2 << std::endl;}return 0;}#include <iostream>int main() {int count = 0;int value;while (std::cin >> value) {if (value < 0) {count++;}}std::cout << "Amount of all negative values read is " << count << std::endl;return 0;}#include <iostream>int main() {int sum = 0, value;while (std::cin >> value) {sum += value;}std::cout << "Sum is " << sum << std::endl;return 0;}#include <iostream>int main() {std::cout << "Enter two numbers:" << std::endl;int v1, v2;std::cin >> v1 >> v2;int lower, upper;if (v1 < = v2) {lower = v1;upper = v2;} else {lower = v2;upper = v1;}for (int val = lower; i <= upper; val++) {std::cout << val << " ";}std::count << std::endl;return 0;}#include <iostream>int main() {std::cout << "Enter two numbers:" << std::endl;int v1, v2;std::cin >> v1 >> v2;int lower, upper;if (v1 < = v2) {lower = v1;upper = v2;} else {lower = v2;upper = v1;}for (int val = lower, int count = 0; i <= upper; val++, count++) {std::cout << val << " ";if (count % 10 == 0) {std::cout << std::endl;}}std::cout << std::endl;return 0;}#include <iostream>#include "Sales_item.h"int main() {Sales_item book;std::cin >> book;std::cout << book << std::endl;return 0;}#include <iostream>#include "Sales_item.h"int main() {Sales_item item1, item2;std::cin >> item1 >> item2;std::cout << item1 + item2 << std::endl;return 0;}#include <iostream>#include "Sales_item.h"int main() {Sales_item total, trans;if (std::cin >> total) {while (std::cin >> trans) {if (total.same_isbn(trans)) {total += trans;} else {std::cout << total << std::endl;total = trans;}}std::cout << total << std::endl;} else {std::cout << "No data ?!" << std::endl;}return 0;}
0 0
- 【C++笔记】第一章 快速入门.cc
- C++Primer学习笔记-----第一章(快速入门)
- C++Primer笔记 第一章 快速入门
- C++Primer学习笔记第一章(1/18)快速入门
- C++Primer 学习笔记 第一章 (快速入门)
- 《C++Primer》 第一章 快速入门
- C++ Primer 第一章 快速入门笔记
- 第一章:XML快速入门
- 第一章 快速入门
- 第一章 快速入门
- 第一章:快速入门
- 第一章 快速入门
- 第一章:快速入门
- 第一章 快速入门
- 第一章 快速入门
- 第一章 快速入门
- 第一章 PHP快速入门
- 第一章快速入门
- USB的工作原理
- Android之Service学习篇一:Service启动方式之startService
- MariaDB数据库安装、配置
- c# use Visual Studio Command create xml's serialitation file by xml file
- 按照周五到周四算做一周
- 【C++笔记】第一章 快速入门.cc
- 将RGB转换成颜色
- Linux系统结构 详解
- object-c的实例变量,局部变量,代码的执行过程
- ubuntu12.04更新源
- STL算法之copy
- struct sockaddr_nl 结构体 由来、含义以及使用——获取Linux路由表
- 如何对商用中央空调进行“降噪”
- 数据结构--线性表总结