- 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语言开发入门与项目实战练习(C language development started with the project practice)
c语言开发入门与项目实战练习(C language development started with the project practice)
1.输出一个n!
# includes stdio.h
main ()
{int i, n;
long p;
printf (enter n:);
scanf (% d, n).
for (i = 1, the = n; i + +)
p = p *.
printf (n! =% ld \ n , p);
}
2.熟悉几个循环的语句
while (! x) x + +;
当 x = 0 时, 执行循环体x + +;
while ((c = getchar ()). = \ n) n = n + 1;
no 称为计数器, 作用是统计输入字符的个数
while (num + + = 2); printf (% d \ n, n);
循环体是空语句, 退出循环后输出num的值
c x = - 3; while (x 5).
先执行循环体x * = - 3, 再判断条件 (x 5)
for n = 0; n 26; n + +) printf (% c, n + a).
作用是输出26个大写字母
for (sum = 0, i = 1, the = 100; sum = sum + 1, i + = 2);
作用是计算100以内的奇数和
3.数值解法计算某点附近的根
# includes stdio.h
# includes math.h
main ()
(float x, x0, f, f1.
printf (输入的初始根x0 =);
scanf (% f, x);
x = 1.5;
i give
{x0 = x;
f = 2 * x0 * x0 * x0 + 4 * x0 * x0 - 7 * x0 - 6;
f1 = 6 * x0 * x0 + 8 * x0 - 7.
x = x0 - f / f1.
} while (two years ago (x - x0) 1 - 6).
printf (% f \ n, x);
}
4.编程序求2~10000以内的完全数
完全数: 一个数的因子 (除了这个数本身) 之和等于该数本身.
main ()
{int i, j, s;
for (i = 2; the = 10000; i + +)
{s = 0;
for (j = 1; j i; j + +)
if (i% j = = 0)
s + = j;
if (i = = d)
printf (% 6d \ n, s);
}
}
5.改写大小写字母
# includes stdio.h
main ()
{
char ch;
ch = putchar ();
if (ch = ch = z)
ch = ch + 32.
printf (% c \ n, ch);
}
6.比较两个数的大小
# includes stdio.h
void main ()
{
int x, y;
printf (输入两个整数, x和y:);
scanf (% d% d x y);
if (x y)
printf (x y \ n );
else
if (x - y)
printf (x y \ n );
else
printf (x = y \ n );
}
7.猴子吃桃
# includes stdio.h
void main ()
{
int i, sum = 1;
for (i = 1, the = 9; i + +)
{
(sum = sum + 1) * 2);
}
printf (% d, sum);
}
8.求100 - 200之间的素数
# includes stdio.h
void main ()
{
int i, k, m;
for (i = 100; the 200; i + +)
for (k = 2; k -; k + +)
{
if the% k = = 0) break; / / 素数的定义
else {
if (i = = k + 1)
{
printf (% d).
m + +; / / 计数
if (m% 5 = = 0) printf (\ n);
}
}
}
}
9.for循环随机显示数
#包括 stdio. h
#包括程序。”
无效main()
{
int c;
为(C = 0;C<10;C++)
{
srand(C + 2);
printf(“随机发生数%d是:%d\n”,C,rand());
}
}
10。求和
#包括 stdio. h
国际娱乐(int x)
{
静态变量t = 0;
返回(T +
您可能关注的文档
- applog(applog).doc
- aptana快捷键(Aptana快捷键).doc
- arcgis server的几个概念(Several concepts of ArcGIS Server).doc
- apmserv提示apache启动失败,请检查相关配置的解决方法(Apmserv prompts Apache failed to start. Please check the solution for the configuration).doc
- arm与嵌入式linux的入门建议 (六步曲)(Arm and embedded Linux entry advice (six steps song)).doc
- arm课程设计(Arm curriculum design).doc
- ar模型(Auto Regression Model).doc
- asa5520防火墙配置(Asa5520 firewall configuration).doc
- asa防火墙命令(ASA firewall command).doc
- atm自动取款机编程(ATM automatic teller machine programming).doc
- c语言成绩管理系统(C language performance management system).doc
- c语言教学11(C language teaching 11).doc
- c语言控制台五子棋(C language console 331).doc
- c语言教学必备(The essential of C language teaching).doc
- c语言教程 第一课(C language tutorial lesson).doc
- c语言教程(课件)1(C language tutorial (courseware) 1).doc
- c语言教程(课件)第1章(C language tutorial (courseware) chapter first).doc
- c语言想过不难啊~(C language is not difficult to think ah).doc
- c语言教程-c语言概论(C language tutorial introduction to -c language).doc
- c语言最重要的知识点复习资料!要学的都来看看。...(C language is the most important knowledge point review to learn to look at. ...).doc
文档评论(0)