- 3
- 0
- 约1.45万字
- 约 35页
- 2017-07-05 发布于河南
- 举报
C程序设计的常用算法(国外英文资料)
C程序设计的常用算法
C programming commonly used algorithms
Source: Electronic Engineer, note, madman, sea time: 2006-03-23 Publisher: Meitai
Algorithm (Algorithm): basic ideas, methods, and procedures for computer problem solving. Description: is the algorithm to solve a problem or methods and steps taken to complete a task description, including what data (input output data, what what results, by what) structure, what statement and how to arrange these statements, etc.. Natural language, structured flowcharts, and pseudo code are often used to describe algorithms.
I. simple algorithms for counting, summing, and calculating factorial
Such problems need to use the cycle, we should pay attention to determine the initial value of the loop variable, the final value or termination conditions, but also pay attention to the enumeration, and the variables of the initial value of variables.
Example: use random function to generate 100 [0, 99] range of random integers, statistics on the number of digits are 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, the number of numbers and print out.
The array is used to handle the problem, and the array a[100] is used to store exactly 100 random integers, and the array x[10] to store the digits on the bit is 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, respectively. That is, the number of bits is 1, stored in x[1], and the number of bits is 2, stored in x[2],...... The number of bits is 0, stored in x[10].
Void, main ()
{int, a[101], x[11], I, p;
For (i=0; i=11; i++)
X[i]=0;
For (i=1; i=100; i++)
{a[i]=rand ()% 100;
Printf (%4d, a[i]);
If (i%10==0) printf (\n);
}
For (i=1; i=100; i++)
{p=a[i]%10;
If (p==0) p=10;
X[p]=x[p]+1;
}
For (i=1; i=10; i++)
{p=i;
If (i==10) p=0;
Printf (%d, %d\n, P, x[i]);
}
Printf (\n);
}
Two, for the two integer greatest common divisor and the least common multiple
Analysis: the common denominator for the algorithm: (LCM = two integer product / GCD)
(1) the m n, known for making mn;
(2) m is divided by N, and the remainder is r;
(3) if r=0, then n is
您可能关注的文档
- !!!变压器的要求和技术参数(国外英文资料).doc
- (上卷)重新学会笑--------中国式新森田教...(国外英文资料).doc
- (宁鸣)晨间(国外英文资料).doc
- (四)津液-(国外英文资料).doc
- (新版)高强轻质高温耐火砖生产制造制备及应用工艺专利技术文集(国外英文资料).doc
- (图解)普林斯顿进攻体系(国外英文资料).doc
- (第1章) 单片机教案(国外英文资料).doc
- (考试时间:70分钟 试卷满分:70分 考试形式:开卷)(国外英文资料).doc
- - 上海LNG加气站 上海CNG加气站博客上海LNG加气站 上海CNG加气站博客(国外英文资料).doc
- ...我相信能耐耐心心看完文章的人,不用再对手机这东西纠结了_百度文库...(国外英文资料).doc
最近下载
- 高压电缆中间头制作措施方案.pdf
- 内容文本分析案例dcc500c机.pdf VIP
- 数学(天津卷02)-2024年高考押题预测卷(全解全析).docx VIP
- 2026年黑龙江林业职业技术学院单招职业适应性测试题库附答案.docx VIP
- 2023年高考押题预测卷02(天津卷)-英语(全解全析).docx VIP
- 2023年高考押题预测卷01(天津卷)-英语(全解全析).docx VIP
- 2024年高考英语临考押题卷01(天津卷)(全解全析).docx VIP
- 高中美术《美术鉴赏》 第一课《培养审美的眼睛——美术鉴赏及其意义》课件共55张.ppt VIP
- 申菱组合式空气处理机组.pdf
- 2024年高考英语临考押题卷02(天津卷)(全解全析) .docx VIP
原创力文档

文档评论(0)