}
void insert(char str[]) {int i;
for (i=strlen(str);i>0;i--) {str[2*i]=str[i]; str[2*i-1]=' '; }
printf(\} 7-9
#include
int letter,digit,space,others; int main()
{void count(char []); char text[80];
printf(\ gets(text);
printf(\ puts(text); letter=0; digit=0; space=0; others=0; count(text);
printf(\ return 0; }
void count(char str[]) {int i;
for (i=0;str[i]!='\\0';i++)
if ((str[i]>='a'&& str[i]<='z')||(str[i]>='A' && str[i]<='Z')) letter++;
else if (str[i]>='0' && str [i]<='9') digit++;
else if (str[i]==32) space++; else
others++; } 7-10
请浏览后下载,资料供参考,期待您的好评与关注!
#include
{int alphabetic(char); int longest(char []); int i;
char line[100];
printf(\ gets(line);
printf(\
for (i=longest(line);alphabetic(line[i]);i++) printf(\ printf(\ return 0; }
int alphabetic(char c)
{if ((c>='a' && c<='z')||(c>='A'&&c<='z')) return(1); else
return(0); }
int longest(char string[])
{int len=0,i,length=0,flag=1,place=0,point; for (i=0;i<=strlen(string);i++) if (alphabetic(string[i])) if (flag) {point=i; flag=0; } else
len++; else
{flag=1;
if (len>=length) {length=len; place=point; len=0; } }
return(place); }
请浏览后下载,资料供参考,期待您的好评与关注!
7-11
#include
{void sort(char []); int i,flag;
for (flag=1;flag==1;)
{printf(\ scanf(\ if (strlen(str)>N)
printf(\ else
flag=0; }
sort(str);
printf(\ for (i=0;i void sort(char str[]) {int i,j; char t; for(j=1;j for (i=0;(i #include {float solut(float a,float b,float c,float d); float a,b,c,d; 请浏览后下载,资料供参考,期待您的好评与关注! printf(\ scanf(\ printf(\ return 0; } float solut(float a,float b,float c,float d) {float x=1,x0,f,f1; do {x0=x; f=((a*x0+b)*x0+c)*x0+d; f1=(3*a*x0+2*b)*x0+c; x=x0-f/f1; } while(fabs(x-x0)>=1e-3); return(x); } 7-13 #include float score[N][M]; float a_stu[N],a_cour[M]; int r,c; int main() { int i,j; float h; float s_var(void); float highest(); void input_stu(void); void aver_stu(void); void aver_cour(void); input_stu(); aver_stu(); aver_cour(); printf(\ NO. cour1 cour2 cour3 cour4 cour5 aver\\n\ for(i=0;i {printf(\ for(j=0;j printf(\ printf(\ 请浏览后下载,资料供参考,期待您的好评与关注! } printf(\ for (j=0;j printf(\ printf(\ h=highest(); printf(\ NO. - course -\\n\ printf(\ return 0; } void input_stu(void) {int i,j; for (i=0;i {printf(\ for (j=0;j scanf(\ } } void aver_stu(void) {int i,j; float s; for (i=0;i {for (j=0,s=0;j void aver_cour(void) {int i,j; float s; for (j=0;j for (i=0;i float highest() {float high; 请浏览后下载,资料供参考,期待您的好评与关注!
《C语言程序设计》课后习题答案(第四版)谭浩强
![](/skin/haowen/images/icon_star.png)
![](/skin/haowen/images/icon_star.png)
![](/skin/haowen/images/icon_star.png)
![](/skin/haowen/images/icon_star.png)