C++ Tutorial/Language Basics/Introduction — различия между версиями
Admin (обсуждение | вклад) м (1 версия: Импорт контента...) |
|
(нет различий)
|
Версия 14:21, 25 мая 2010
Содержание
Calculating with integer constants
#include <iostream>
using std::cout;
using std::endl;
int main() {
cout << 1 + 2 << endl;
cout << 1 - 5 << endl;
cout << 1 - 2 << endl;
cout << 1 * 2 << endl;
cout << 1/3 << endl;
cout << 1 3 << endl;
cout << 1 -3 << endl;
cout << -1 3 << endl;
cout << -1 -3 << endl;
cout << 1 + 2/1 - 5 << endl;
cout << (1 + 2)/(1 - 5) << endl;
cout << 1 + 2/(1 - 5) << endl;
cout << (1 + 2)/1 - 5 << endl;
cout << 4*5/3 + 7/3 << endl;
return 0;
}
3 -4 -1 2 0 1 1 -1 -1 -2 0 1 -2 4
This is a simple C++ program
#include <iostream>
using namespace std;
int main()
{
cout << "www.java2s.com";
return 0;
}
www.java2s.com"
Using the assignment operator
#include <iostream>
using std::cout;
using std::endl;
int main() {
int a = 10;
int b = 6;
int c = 3;
int d = 4;
int f = (a + b)/(c + d);
cout << f ;
return 0;
}
2
Working with integer variables
#include <iostream>
using std::cout;
using std::endl;
int main() {
int a = 10;
int b = 3;
cout << a/b;
cout << a b;
return 0;
}
31