2019年4月6日

例4-12 穷举算法-搬砖

摘要: 例4 12 穷举算法 搬砖 男人三块、女人两块、小孩两人一块,45人搬45块、求方案 程序核心——多for语句镶嵌 1程序 include int main() { int child,men,women; for(men=0;men int main() { int child,men,women 阅读全文

posted @ 2019-04-06 09:55 凯*凯 阅读(555) 评论(0) 推荐(0) 编辑

例4-11 斐波那契数列输出

摘要: 例4 11 斐波那契数列输出 1 1 2 3 5 8…… 程序核心——for语句 程序 include int main() { int i,x1=1,x2=1,x; printf("%d %d ",x1,x2); for(i=1;i 阅读全文

posted @ 2019-04-06 09:47 凯*凯 阅读(218) 评论(0) 推荐(0) 编辑

例4-9 逆序输出数字

摘要: 例4 9 逆序输出数字 输入一个正整数,将其逆序输出 程序核心——while语句 程序 结果 分析 重点:while语句先循环再判断 阅读全文

posted @ 2019-04-06 09:31 凯*凯 阅读(146) 评论(0) 推荐(0) 编辑

例4-8 最大成绩

摘要: 例4 8 最大成绩 找到最大成绩 程序核心——比较for语句与while语句 for程序 include int main() { int i,mark,max,n; printf("Enter n:"); scanf("%d",&n); printf("Enter %d marks:",n); s 阅读全文

posted @ 2019-04-06 09:11 凯*凯 阅读(62) 评论(0) 推荐(0) 编辑

例4-7 求1!+2!+…+100!

摘要: 例4 7 求1!+2!+…+100! 计算 1!+2!+…+100! 程序核心——两个循环的镶嵌 程序 include int main() { int i,j,n; double sum,result; sum=0; for(i=1;i 阅读全文

posted @ 2019-04-06 09:03 凯*凯 阅读(142) 评论(0) 推荐(0) 编辑

例4-6 求1!+2!+…+100!

摘要: 例4 6 求1!+2!+…+100! 计算1!+2!+…+100! 程序核心——累积累乘的两个循环 程序 include double fact(int n); int main() { int i; double sum; sum=0; for(i=1;i 阅读全文

posted @ 2019-04-06 08:59 凯*凯 阅读(117) 评论(0) 推荐(0) 编辑

例4-5 猜数游戏 产生随机数

摘要: 例4 5 猜数游戏 产生随机数 改例3 1、自动生成随机数、 程序核心——srand(time(0));//刷新随机数 mynumber=rand()%100+1;//产生随机数 程序 结果 分析 重点:srand函数在stdlib.h头文件中,time函数在time.h头文件中。srand一般与r 阅读全文

posted @ 2019-04-06 08:50 凯*凯 阅读(209) 评论(0) 推荐(0) 编辑

例4-4 判断素数

摘要: 例4 4 判断素数 读入整数,判断是否为素数 程序核心——for语句、break语句 程序 结果 分析 重点:break语句跳出循环、判断 阅读全文

posted @ 2019-04-06 08:43 凯*凯 阅读(117) 评论(0) 推荐(0) 编辑

2019年4月5日

例4-10 输出100之内的素数——循环镶嵌

摘要: 例4 10 输出100之内的素数——循环镶嵌 程序核心——镶嵌 程序 结果 分析 重点:镶嵌 阅读全文

posted @ 2019-04-05 22:01 凯*凯 阅读(160) 评论(0) 推荐(0) 编辑

例4-2 求平均分

摘要: 例4 2 求平均分 更改例3 3,计算平均分、统计不合格人数 程序核心——if语句 程序 include int main() { int count,num; double grade,total; num=total=count; printf("Enter grades:"); scanf(" 阅读全文

posted @ 2019-04-05 21:54 凯*凯 阅读(96) 评论(0) 推荐(0) 编辑

导航