//2023.2.4渔火 Linux迷 www.linuxmi.com
int main()
{
int n=13,year;
double number,rate=0.02;
for(year=1;year<=10;year++)
{
number=n*pow((1+rate),year);
printf("%2d年后,人数为:%.2f亿\n",year,number);
}
//2023.2.4渔火 Linux迷 www.linuxmi.com
return ;
}
linuxmi /home/linuxmi/www.linuxmi.com
⚡ gcc linuxmi.c -lm -o linuxmi
linuxmi /home/linuxmi/www.linuxmi.com
⚡ ./linuxmi
1年后,人数为:13.26亿
2年后,人数为:13.53亿
3年后,人数为:13.80亿
4年后,人数为:14.07亿
5年后,人数为:14.35亿
6年后,人数为:14.64亿
7年后,人数为:14.93亿
8年后,人数为:15.23亿
9年后,人数为:15.54亿
10年后,人数为:15.85亿
{
number=n*pow((1+rate),year);
printf("%2d年后,人数为:%.2f亿\n",year,number);
}
//2023.2.4渔火 Linux迷 www.linuxmi.com
int main()
{
int i,n;
double fac;
printf("输入n的值:");
scanf("%d",&n);
fac=1;
for(i=1;i<=n;i++)
fac=fac*i;
printf("%d!=%.0f\n",n,fac);
//2023.2.4渔火 Linux迷 www.linuxmi.com
return ;
}
//2023.2.4渔火 Linux迷 www.linuxmi.com
int main()
{
int i;
float x,max;
printf("请输入第1个数:");
scanf("%f",&x);
max=x;
for(i=1;i<=9;i++)
{
printf("请输入第%d个数",i+1);
scanf("%f",&x);
if(x>max)
max=x;
}
printf("10个数的大值是:%.0f",max);
//2023.2.4渔火 Linux迷 www.linuxmi.com
return ;
}
//2023.2.4渔火 Linux迷 www.linuxmi.com
int main()
{
int num,a,b,c;
for(num=100;num<=999;num++)
{
a=num/100;
b=num%100/10;
c=num%10;
if(num==a*a*a+b*b*b+c*c*c)
printf("%5d",num);
}
//2023.2.4渔火 Linux迷 www.linuxmi.com
return ;
}
//2023.2.4渔火 Linux迷 www.linuxmi.com
int main()
{
int n=,i;
char ch;
printf("输入3个数字:");
for(i=1;i<=3;i++)
{
scanf("%c",&ch);
n=n*10+ch-'0';
}
printf("%d\n",n);
//2023.2.4渔火 Linux迷 www.linuxmi.com
return ;
}
相关链接:
https://www.linuxmi.com/learn-c-language-from-scratch-1.html
https://www.linuxmi.com/learn-c-language-from-scratch-2.html
https://www.linuxmi.com/learn-c-language-from-scratch-3.html
https://www.linuxmi.com/learn-c-language-from-scratch-4.html
-
https://www.linuxmi.com/learn-c-language-from-scratch-5.html