写在前面的话
这个是楼主大一入门时的课程作业代码,很多当时也写得较为粗糙,
后来逐渐掌握后也没进一步优化的想法和必要,此文纯粹记录,参考作用不大。
实验平台为Visual-Studio-2017
前面的 #include "pch.h"
文件如下:
// 入门提示:
// 1. 使用解决方案资源管理器窗口添加/管理文件
// 2. 使用团队资源管理器窗口连接到源代码管理
// 3. 使用输出窗口查看生成输出和其他消息
// 4. 使用错误列表窗口查看错误
// 5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
// 6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
#ifndef PCH_H
#define PCH_H
// TODO: 添加要在此处预编译的标头
#endif //PCH_H
- Hello World
#include "pch.h"
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
system("pause");
}
- 第一个应用程序(加法)
#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
int a,b;
cin >> a >> b;
cout << a + b;
system("pause");
}
- 生日祝福的贺卡模板
#include "pch.h"
#include<stdio.h>
#include<windows.h>
#include<conio.h>
#include<math.h>
//____________________________
#define N 100//产生随即颜色
//____________________________
extern char s_1[] = {
"☆ " };
extern char s_2[] = {
"☆ " };
extern char s_3[] = {
"☆ " };
extern char s_4[] = {
"☆ " };
extern char s_5[] = {
"☆ " };
extern char s_6[] = {
"☆ " };
extern char s_7[] = {
"☆ " };
extern char s_8[] = {
"☆ " };
extern char s_9[] = {
"☆ " };
extern char s_10[] = {
"☆ " };
extern char s_11[] = {
"☆ " };
extern char s_12[] = {
"☆ " };
extern char s_13[] = {
"☆ " };
extern char s_14[] = {
"☆ " };
extern char s_15[] = {
"☆ " };
extern char s_16[] = {
"☆ " };
extern char s_17[] = {
" " };
extern char s_18[] = {
" " };
extern char s_19[] = {
" 2018.12-18" };
extern char * ssum[] = {
s_1,s_2,s_3,s_4,s_5,s_6,s_7,s_8,s_9,s_10,s_11,s_12,s_13,s_14,s_15,s_16,s_17,s_18,s_19 };
//__________________________________
char randk();
void main() {
int i = 0;
long f = 0;
char s[10] = "color ";
puts("\n\n\n\n\n\n\n\n\n\n ");
for (i = 0; i < N; i++) {
//要变色的次数
s[6] = randk(); s[7] = randk();
system(s);//调用cmd的color命令
printf