一.函数;
1.函数的定义和调用
2.函数的声明
3.函数的分类
4.函数的值传递
5.函数的分文件编写
//#define _CRT_SECURE_NO_WARNINGS
//#include<stdio.h>
//#include<string.h>
//#include<stdlib.h>
//#include "test.h"
//
//
//int main()
//{
// int a = 10;
// int b = 20;
// printf("a + b = %d\n", add(a, b));
// printf("a - b = %d\n", sub(a, b));
//
// system("pause");
// return EXIT_SUCCESS;
//}
6.exit和return的区别
7.随机数案例
8.打字游戏案例
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <time.h>
#include <conio.h>
int main()
{
//随机数种子
srand((unsigned int)time(NULL));
//1、准备数组 存放随机英文字符
char buf[20 + 1] = { 0 };
//2、产生随机数
for (int i = 0; i < 20; i++)
{
buf[i] = rand() % 26 + 'a';
}
printf("%s\n", buf);
int count = 0; //正确输入个数
//3、用户输入,并检测
for (int i = 0; i < 20; i++)
{
char ch = _getch(); //头文件 conio.h
if (ch == buf[i])
{
printf("%c", ch);
count++;
}
else
{
printf("_");
}
}
printf("\n");
printf("正确率为:%.2lf%%\n", (double)count / 20 * 100);
system("pause");
return EXIT_SUCCESS;
}