c第三章课后习题答案-谭浩强

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
cout<<"sq="<<st;endl;
cout<<"vq="<<setw(10)<<vq<<endl;
cout<<"vz="<<setw(10)<<vz<<endl;
return 0;
}

#include <iostream>
using namespace std;
int main ()
cin>>year>>month>>day;
cout<<year<<"/"<<month<<"/"<<day;
days=sum_day(month,day);
数一
*/
if(leap(year) && month>=3)

*//*调用函/*调用函数days=days+1;
cout<<" is the "<<days<<"th day in this year."<<endl;
case 6: grade='D';break;
default:grade='E';
}
cout<<"score is "<<score<<", grade is "<<grade<<endl;
return 0;
}

#include <iostream>
using namespace std;
int main ()
ch[j]=155-ch[j];
else if ((ch[j]>='a') && (ch[j]<='z'))
}
cout<<"original text:";
cout<<ch<<endl;
return 0;
}

ch[j]=219-ch[j];
j++;
#include <iostream>
#include <string>
int main()
{double solut(double ,double ,double ,double );
double a,b,c,d;
cout<<"input a,b,c,d:";
cin>>a>>b>>c>>d;
cout<<"x="<<solut(a,b,c,d)<<endl;
return 0;
{float c,f;
cout<<"请输入一个xx:";
cin>>f;
c=*(f-32);;
cin>>score;
}
switch(int(score/10))
{case 10:
case 9: grade='A';break;
case 8: grade='B';break;
case 7: grade='C';break;
else if (num>999)
place=4;
else if (num>99)
place=3;
else if (num>9)
place=2;
else place=1;
cout<<"place="<<place<<endl;
.="<<sn<<endl;
return 0;
}

#include <iostream>
cout<<"P"<<n<<"(x)="<<p(n,x)<<endl;cout<<n<<"="<<a<<"+"<<b<<endl;}}return 0;
}
float p(int n,int x)
{if (n==0)
return(1);
else if (n==1)
return(x);
else
return(((2*n-1)*x*p((n-1),x)-(n-1)*p((n-2),x))/n);

#include <iostream>
#include <iomanip>
using namespace std;
int main ( )
{float h,r,l,s,sq,vq,vz;
const float pi=;
cout<<"please enter r,h:";
cin>>r>>h;
l=2*pi*r;
cin>>x;
sinh=(e(x)+e(-x))/2;
cout<<"sinh("<<x<<")="<<sinh<<endl;
return 0;
}
double e(double x)
{return exp(x);}

#include <iostream>
#include <cmath>
using namespace std;
}
int prime(int n)
{int flag=1,i;
for (i=2;i<n/2 && flag==1;i++)
if (n%i==0)
flag=0;
return(flag);
}

#include <iostream>
using namespace std;
int main()
{int fac(int);
}

#include <iostream>
using namespace std;
int main()
{void hanoi(int n,char one,char two,char three);
int m;
cout<<"input the number of diskes:";
cin>>m;
cout<<"The steps of moving "<<m<<" disks:"<<endl;
return(x);
}

#include <iostream>
#include <cmath>
using namespace std;
int main()
{void godbaha(int);
int n;
cout<<"input n:";
cin>>n;
godbaha(n);
return 0;
}
void godbaha(int n)
int a,b,c,sum=0;
cout<<"enter a,b,c:";
cin>>a>>b>>c;
sum=sum+fac(a)+fac(b)+fac(c);
cout<<a<<"!+"<<b<<"!+"<<c<<"!="<<sum<<endl;
return 0;
}
int fac(int n)
{int f=1;
using namespace std;
int main ()
{float s=0,t=1;
int n;
for (n=1;n<=20;n++)
{
t=t*n;.+20!="<<s<<endl;
return 0;
}

#include <iostream>
using namespace std;
int main ()
}
double solut(double a,double b,double c,double d)
{double 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-5);
s=r*r*pi;
sq=4*pi*r*r;
vq=*pi*r*r*r;
vz=pi*r*r*h;
cout<<setiosflags(ios::fixed)<<setiosflags(ios::right)
<<setprecision(2);
cout<<"l= "<<setw(10)<<l<<endl;
cout<<"s= "<<setw(10)<<s<<endl;
else if ((ch[j]>='a') && (ch[j]<='z'))
}
cout<<"original text:";
cout<<tran<<endl;
return 0;
}
另一解
tran[j]=219-ch[j];
tran[j]=ch[j];
else
j++;
#include <iostream>
#include <string>
using namespace std;
int main()
{int j;
string ch="I will visit China next week.";
cout<<"cipher code:"<<ch<<endl;
j=0;
while (j<=())
{ if ((ch[j]>='A') && (ch[j]<='Z'))
for (int i=1;i<=n;i++)
f=f*i;
return f;
}

#include <iostream>
#include <cmath>
using namespace std;
int main()
{double e(double);
double x,sinh;
cout<<"enter x:";
return 0;
}
int sum_day(int month,int day),tran;
tran=ch;
cout<<"cipher code:"<<ch<<endl;
j=0;
while (j<=())
{ if ((ch[j]>='A') && (ch[j]<='Z'))
tran[j]=155-ch[j];
}

#include <iostream>
using namespace std;
int main()
{const int m=1000;.,k10
{case 1:
k1=i;break;<<endl;
return 0;
else
cout<<n<<" is not a prime."<<endl;
return 0;
using namespace std;
int main()
{char s1[80],s2[40];
int i=0,j=0;
cout<<"input string1:";
cin>>s1;
cout<<"input string2:";
cin>>s2;
while (s1[i]!='\0')
ch[j]=155-ch[j];
else if ((ch[j]>='a') && (ch[j]<='z'))
ch[j]=219-ch[j];
j++;
}
cout<<"original text:";
cout<<ch<<endl;
return 0;
}
#include <iostream>
#include <string>
else return 0;
}

#include <iostream>
using namespace std;
int main()
{int x,n;
float p(int,int);
cout<<"input n & x:";
cin>>n>>x;
cout<<"n="<<n<<",x="<<x<<endl;;
}
return 0;
}

#include <iostream>
using namespace std;
int main()
{int sum_day(int,int);
int leap(int year);
int year,month,day,days=0;
cout<<"input date(year,month,day):";
{int i,j,k,n;
cout<<"narcissus numbers are:"<<endl;
相关文档
最新文档