- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
北邮C上上机课第二章及第三章
第二章
(1)
#includeiostream
#includeiomanip
using namespace std;
void main()
{
char ch;
cout请输入小写字母:endl;
cinch;
cout输出的大写字母:(char)toupper(ch)endl;
}
(2)
#includeiostream
#includeiomanip
using namespace std;
void main()
{
int a,b,c;
coutsetw(20)请输入一个整数:\t;
cina;
b=a*a;
c=a*a*a;
coutsetw(20)此数的平方是=bendl;
coutsetw(20)此数的立方是=cendl;
}
(3)#include iostream
using namespace std;
void main()
{
int a,b,c;
cout请输入一个三位以上的整数:;
cina;
b=a/10;
c=b%10;
cout结果是:cendl;
}
(4)
#include iostream
using namespace std;
void main()
{
int a,b,c,d,n;
cout请输入一个三位正整数:;
cina;
b=a/100;
c=(a-b*100)/10;
d=(a-b*100)%10;
n=d*100+c*10+b;
cout转化结果是:n\n;
}
(5)
#include iostream
#include cmath
using namespace std;
void main()
{
double PI=3.14159,a,b,c,d,t;
int m=180;
cout请输入一个锐角:;
cina;
t=(a/m)*PI;
b=sin(t);
c=cos(t);
d=tan(t);
cout正弦值:b余弦值:c正切值:dendl;
}
(6)
#include iostream
using namespace std;
void main()
{
coutchar :sizeof(char)字节endl;
coutint :sizeof(int)字节endl;
coutfloat :sizeof(float)字节endl;
coutdouble :sizeof(double)字节endl;
coutbool :sizeof(bool)字节endl;
}
第三章
(1)
#include iostream
using namespace std;
void main()
{
int a=123456,b,c,d;
cout请输入六位密码:endl;
cinb;
if (a==b);
cout欢迎使用财会报表程序endl;
else
cout密码错,重新输入!endl;
cinc;
if (a==c)
cout欢迎使用财会报表程序endl;
else
cout密码错,重新输入!endl;
cind;
if (a==d)
cout欢迎使用财会报表程序endl;
else
cout拒绝使用财会软件endl;
}
(2)
#includeiostream
#includeiomanip
using namespace std;
void main()
{
int i=100,a,b,c,d;
while(i1000)
{
a=i/100;
b=(i-a*100)/10;
c=(i-a*100)%10;
d=a*a*a+b*b*b+c*c*c;
if(d==i)
{cout水仙花数是:iendl;}
i=i++;
}
}
(3)
#includeiostream
#includeiomanip
using namespace std;
void main()
{
int a,b;
cout请输入年、月:;
cinab;
if(b==1||b==3||b==5||b==7||b==8||b==10||b==12)
cout这个月有31天endl;
else
if(b==4||b==6||b==9||b==11)
cout这个月有30天endl;
else
if(b==2a%4==0a%100!=0||a%400==0)
cout这个月有29天endl;
else
cout这个月有28天endl;
}
(4)
#includeiostream
using namespace std;
void main()
{
int row;
cout请输入行数:;
cinrow;
int n,i,j;
原创力文档


文档评论(0)