|
#include<stdio.h>
//宏定义
#define PI 3.14//宏定义有意义的数字
#define u8 unsigned char//简写长类型符
#define u16 unsigned short
#define u32 unsigned int
//函数定义
void Addiction();//加法函数
int Factoral_10();//20的阶乘函数,用来实现阶乘,然后输出结果
void Judge(int a);//判断函数
float CircleArea(float a);//圆面积函数定义
int main()
{
int num1=0;
float Area1=0;
Addiction();
num1 = Factoral_10();
printf("%d\n",num1);
Judge(100);
Judge(72);
Judge(66);
Judge(50);
Area1 = CircleArea(2);
printf("%f\n",Area1);
return 0;
}
void Addiction()
{
static int sum = 0;
int i=1;
while(i<=10)
{
sum = sum + i;
i++;
}
printf("%d\n",sum);
printf("%d\n",i);
}
int Factoral_10()
{
int num = 1,j;
for(j=1;j<=10;j++)
{
num = num * j;
}
return num;
}
void Judge(int a)
{
if(a>=80)
{
printf("A\n");
}
else if(a>=70)
{
printf("B\n");
}
else if(a>=60)
{
printf("C\n");
}
else
{
printf("D\n");
}
}
float CircleArea(float r)
{
float area;
area = PI*r*r;
return area;
}
//心得:①要慢慢学会使用IAR开发工具
//②变量要赋初值,不然可能得不到想要的答案
//代码要多敲,才能有感觉 |
|