1. Mathematical functions
1. abs():
Prototype of absolute value function used to calculate and output integer data: int abs(int val);
2. fabs():
Prototype of absolute value function used to calculate and output floating-point data: double fabs (double val);
3. pow(): used for exponentiation calculation
function prototype: double pow(double x, double y);//x to the power of y
4. sqrt(): used to calculate and output floating-point number x The square root
function prototype: double sqrt(double x);
2. Two methods to realize multiple sets of input
method one:
#include<stdio.h>
int main()
{
int a,b;
while(~scanf("%d%d", &a, &b))
{
printf("%d\n",a+b);
}
return 0;
}
Method Two:
#include<stdio.h>
int main()
{
int a,b;
while(scanf("%d%d", &a, &b)!=EOF)
{
printf("%d\n",a+b);
}
return 0;
}
3. Calculate 1977!
#include <stdio.h>
int main()
{
int a[5660]={
0},n=1,t=0,flag;
a[0]=1;
for(int i=1;i<1978;i++)
{
for(int j=0;j<n;j++)
{
a[j]=a[j]*i+t;
if(a[n-1]>=10)
n++;
if(a[j]>=10)
{
t=a[j]/10;
a[j]%=10;
flag=j;
}
if(j>flag)
t=0;
}
}
for(int i=n-1;i>=0;i--)
printf("%d",a[i]);
}