#include//嵌套循环
int main(){
const int ROWS=6;
const int C=6;
int row;
char ch;
for(row=0;row
{
for(ch=('A'+row);ch
printf("%c",ch);
printf("/n");
}
getch();
return 0;
}
#include//10个数求平均 ,数组在for的用法
int main()
{
const int SIZE=10;
int index,num[SIZE];
int sum=0;//注意这里,sum=0
float average;
printf("请输入10个分数:");
for(index=0;index
scanf("%d",&num[index]);
printf("这几个数分别是/n");
for(index=0;index
printf("%5d",num[index]);
printf("/n");
for(index=0;index
sum+=num[index];//先加index
average=(float)sum/SIZE;//强制数组转换
printf("平均数为:%.3f/n" ,average);
getch();
return 0;
}
#include//函数返回值
double power(double n,int p);
int main(){
double x,xpow;
int exp;
printf("Please enter a pair of numbers or q to quit/n");
while(scanf("%lf%d",&x,&exp)==2)
{
xpow=power(x,exp);
printf("%.3g to the power %d is %.5g/n",x,exp,xpow);
printf("please entet next pair of numbers or q to quit/n");
}
printf("hope you enjoyed this power trip/n");
getch();
return 0;
}
double power(double n,int p){
double pow=1;
int i;
for(i=1;i<=p;i++)
pow*=n;
return pow;
}