自考高级语言程序设计大题,考点是编写函数和调用,求标准答案,跪求答案,回答得好追加悬赏

1 (1) 编写一个计算摄氏温度(C)到华氏温度(F)转换的函数。函数头是:float temp(float ) 计算公式:F=9/5C+32
(2) 编写主函数从键盘输入摄氏温度的值,调用上述函数输出摄氏温度以及华氏温度的值(小数点后保留2位小数)
2 用循环结构实现下列问题:现有1020本书,第一天卖掉一半多2本,以后每天卖掉剩下的一半多2本,直到卖完为止,计算并输出卖完需要的天数。
3 (1) 编写一函数,讲指针变量p1和p2所指向的整数值交换。

其中:函数头是 viod swap (int *p1,int*p2)
(2) 编写一个主程序,从键盘输入2个整数,调用上述函数实现两个数据交换并输出。

4.输入10个整数到数组a中并输出,将数组各元素依次向后循环移动一个位置(如下图),输出移动后的数组a。
移动前: a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8] a[9]

移动后:a[9] a[0] a[1] a[2] a[3] a[4] a[5] a[6] a[7] a[8]
用标准的C来编写 谢谢各位大虾了 要分一小问一小问答啊 考点是编写函数 然后是用调用编写的函数 第一小问我打错了应该是 函数头:float temp(float c)计算公式:F=9/5C+32

1(1)
float temp(float c)
{
return (9.0/5.0*c+32);
}
(2)
#include "stdio.h"
void main()
{ float temp(float c);
float c,f;
printf("请输入一个摄氏温度:");
scanf("%f",&c);
f=temp(c);
printf("华氏温度为:%5.2f\n",f);
}
float temp(float c)
{
return (9.0/5.0*c+32);
}
2
#include "stdio.h"
void main()
{ int total=1020;
int day=0;
while(total>=0)
{total=total/2-2;
day++;
}
printf("day=%d\n",day);
}
3(1)
void swap(int *p1,int *p2)
{int temp;
temp=*p1;
*p1=*p2;
*p2=temp;
}
(2)
void main()
{void swap(int *p1,int *p2);
int a,b,*q1,*q2;
scanf("%d %d",&a,&b);
q1=&a;
q2=&b;
swap(q1,q2);
printf("%d,%d\n",a,b);
}
void swap(int *p1,int *p2)
{int temp;
temp=*p1;
*p1=*p2;
*p2=temp;
}
4
#include "stdio.h"

void main()
{void inv(int x[],int n);
int i,a[10];
for(i=0;i<10;i++)
scanf("%d",&a[i]);
printf("移动前:\n");
for(i=0;i<10;i++)
printf("%d",a[i]);
printf("\n");
inv(a,10);
printf("移动后:\n");
for(i=0;i<10;i++)
printf("%d",a[i]);
printf("\n");
}
void inv(int x[],int n)
{int i,j=x[n-1];
for(i=n-2;i>=0;i--)
{
x[i+1]=x[i];
} x[0]=j;

return;
}
//皆调试运行正确!!
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-10-22
同第一个。
相似回答