TA的每日心情 | 开心 2014-6-18 08:29 |
---|
签到天数: 14 天 [LV.3]偶尔看看II
滴水大师
 
- 积分
- 2345
|
题目
解决代码及点评
- <pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"></pre><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code"><pre code_snippet_id="91880" snippet_file_name="blog_20131202_1_2646179" class="cpp" name="code">/************************************************************************/
- /*
- 76. 编写“N个人放鞭炮问题的程序”。
- N个人同时刻开始放鞭炮, 第一个人每隔T1秒放一次,
- 第二个人每隔T2秒放一次,...第N个人每隔Tn秒放一次。
- 每个人各放M个鞭炮。问总共能听到多少次鞭炮声。
- //实质是找出来 (N-1)*TN 中不能被 t1 t2... tn 整出的数
- */
- /************************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <string.h>
-
- void main()
- {
- const int N=5;//人数
- const int M=5;//次数
- int arr1[N]={1,2,3,4,5};
- bool arr[N*N]={0};
- for (int i=0;i<N;i++)
- {
- int temp=0;
- for (int j=0;j<M;j++)
- {
- arr[temp]=1;
- temp+=arr1;
-
- }
-
- }
- int num=0;
- for (int i=0;i<N*N;i++)
- {
- if (arr==1)
- {
- num++;
- printf("%5d",i);
- }
-
- }
- printf("\n");
- printf("%d",num);
- system("pause");
- }</pre><br><br><br></pre></pre></pre>
|
|