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 numbers
std::cout << "Enter two numbers:" << std::endl;
int v1, v2; // uninitialized
std::cin >> v1 >> v2; // read input
return 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;
}
08-16
08-16