1.2 C++快速入门

1.1 信息在计算机中的表示

1.2 C++快速入门

新标准C++程序设计 郭炜 编著ios

第一个C++程序

#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	printf("Hello, world!");
	return 0;
}
//Result: Hello, world!

第二个C++程序:输出更多

#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int a  = 3;
	printf("I have %d dollars.\n", a);
	printf("I want to buy:\na book.");
	return 0;
}
/* result is as follows:
I have 3 dollars.
I want to by:
a book.
*/

第三个C++程序:如何输入

输入两个整数,输出它们的和(NOI. POJ 7883)spa

#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d", a+b);
	return 0;
}
/** Input & Output is as follows:
3 4 <Enter>
7
**/

第四个C++程序:输入字符

#include <cstdio>
#incluce <iostream>
int main()
{
	char a, b, c;
	scanf("%c%c%c", &a, &b, &c);
	printf("%c%c%c", a, b, c);
	return 0;
}
/* I & O:
x y
x y
*/
相关文章
相关标签/搜索