4、
①sum=0;i = 1;
②i<=100
③i++;
④%f
5、
①25
②arrA[0]
③arrA[1]
④i=2
⑤i<25
⑥arrA[i-2]
6、
① n = 0;
②i<10
③arrA[n]
④n = i;
7、
①dblA = 1
② i<=n
③dblA
④i,jc(i)
以下是经上机调试过的源程序,给你参考参考!
void main()
{
int i;
double sum;
sum=0;i = 1;
while(i<=100)
{
sum = sum + i;
i++;
}
printf("sum=%f\n",sum);
}
5、void main()
{
double arrA[25];
int i;
arrA[0] = 1;
arrA[1] = 1;
for(i=2; i<25; i++ )
{
arrA[i] = arrA[i-2] + arrA[i-1];
}
for( i = 0; i < 25; i++ )
{
printf("%8.0f",arrA[i]);
if( (i+1) % 5 == 0 ) printf("\n");
}
}
6、void main()
{
int arrA[10] = {24,15,35,9,86,7,89,68,47,79};
int n,i;
n = 0;
for( i = 1; i<10; i++ )
{
if( arrA[i] >arrA[n])
n = i;
}
printf("The max is arrA[%d] = %d",n,arrA[n]);
}
7、#include "stdafx.h"
double jc(int n)
{
double dblA = 1;
int i;
for( i = 1; i<=n; i++ )
dblA *= i ;
return dblA;
}
void main()
{
int i;
for( i = 1; i <=20; i++ )
printf("%d! = %f\n",i,jc(i));
}
自己做出来的才是最真的,靠人家始终不是办法啊,你以后工作了还能靠人家吗,现在考试抄下你还是不懂是没用的啊!仔细看下书就会明白的不要嫌麻烦,嫌麻烦是学不着东西的啊!
4 sum=0;i<100;i++;%d