1.编译软件的安装与使用
直接下载安装版,然后点击程序进入,建议选择白色主题(不伤眼),下面图示说明,当然也可以直接在在线平台上学习操作(如ACWING:https://www.acwing.com/)
https://royqh1979.gitee.io/redpandacpp/
2.作业的评测与提交
推荐北大闫学灿学长的ACWING网站(你也可以报他的课程,性价比极高)
在线练习地址:www.acwing.com
作业提交地址:https://www.acwing.com/activity/content/21/
#includeusing namespace std; int main() { cout << "Hello World" << endl; return 0; }
F10,保存并运行,查看结果。恭喜你!全世界所有程序员的第一个程序编译测试完成!
变量必须先定义,才可以使用。不能重名。
变量定义的方式:
#includeusing namespace std; int main() { int a = 5; int b, c = a,d = 10 / 2; return 0; }
常用变量类型及范围:
#include字符串的输入输出:using namespace std; int main() { int a, b; cin >> a >> b ; cout << a + b << endl; return 0; }
#include输入输出多个不同类型的变量:#include using namespace std; int main() { string str; cin >> str; cout << str << endl; return 0; }
#include3.表达式 整数的加减乘除四则运算:#include using namespace std; int main() { int a, b; string str; cin >> a; cin >> b >> str; cout << str <<"!!!" << a + b << endl; return 0; }
#include浮点数(小数)的运算:#include using namespace std; int main() { int a = 6 + 8 * 4 / 2 - 2; cout << a << endl; int b = a * 4 + 10 / 2; cout << b << endl; cout << 25 * 56 - 88 / 4 << endl; return 0; }
#include#include using namespace std; int main() { float x = 1.3, y = 3.4; cout << x * y << ' ' << x + y < 整型变量的自增、自减: #include#include using namespace std; int main() { int a = 1; int b = a ++; cout << a << ' ' << b < 变量的类型转换: #include#include using namespace std; int main() { float x = 133.56; int y = (int)x; cout << x << ' ' << y < 4.顺序语句 (1)输出第二个整数: #include(2)计算 (a + b) * c的值#include using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << b << endl; return 0; } #include(3)带余除法#include using namespace std; int main() { int a, b, c; cin >> a >> b >> c; cout << (a + b) * c << endl; return 0; } #include(4)求反三位数:#include using namespace std; int main() { int a, b; cin >> a >> b; int c = a / b, d = a % b; cout << c << ' ' << d << endl; return 0; } #include(5)交换两个整数#include using namespace std; int main() { int n; cin >> n; int a = n % 10; n = n / 10; int b = n % 10; n = n / 10; int c = n ; cout << a << b << c << endl; return 0; } #include(6)输出菱形#include using namespace std; int main() { int a=20; int b=30; int c = b; b = a; a = c; cout << a <<' '<< b << endl; return 0; } #include#include using namespace std; int main() { char a; cin >> a; cout << " " << a << endl; cout << " " << a << a << a << endl; cout << a << a << a << a << a << endl; cout << " " << a << a << a << endl; cout << " " << a << endl; return 0; }



