堃鹏
2018-10-31 19:19
有哪位大佬知道
#include<stdio.h>
int main()
{
int i,n,x;
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(i<=(n+1)/2)
{
for(x=(n-1)/2;x>=i;x--)
{
printf(" ");
}
for(x=1;x<=2*i-1;x++)
{
printf("*");
}
printf("\n");
}
else
{
for(x=1;x<=i-(n+1)/2;x++)
{
printf(" ");
}
for(x=(n-i+1)*2-1;x>=1;x--)
{
printf("*");
}
printf("\n");
}
}
return 0;
}
#include<stdio.h>
int fenzi(int a)
{
if(a == 1)
return 2;
else if(a == 2)
return 3;
else
return fenzi(a - 1)+fenzi(a - 2);
}
int main()
{
int n, a;
float sum;
sum = 0;
scanf("%d", &n);
for(a = 1; a <= n; a++)
{
if(a == 1)
{
sum += 1.0 * fenzi(a) / 1;
}
else
{
sum += 1.0 * fenzi(a) / fenzi(a - 1);
}
}
printf("%.2f", sum);
return 0;
}
像这个题我打出代码来,答案错误
谢谢大佬
C语言入门
926025 学习 · 20793 问题
相似问题