void calc_probability(int num)
{
int i = , j = , k = ;
#define SIZE_NUM 8
int *array_num = NULL;
int *remember_num = NULL;
char (**array_detail)[SIZE_NUM] = NULL; //数组指针
int len_array = ;
int count_num = ;
int count = ; len_array = * num - ;
array_num = (int*)calloc(len_array, sizeof(int));
array_detail = (char (**)[SIZE_NUM])calloc(len_array, sizeof(char(*))); //这里注意是sizeof(char(*)不是sizeof(char(*)[SIZE_NUM])
remember_num = (int*)calloc(len_array, sizeof(int)); for(i = ; i < len_array; i++)
{
array_num[i] = i + ;
array_detail[i] = (char(*)[SIZE_NUM])calloc(count_num + , sizeof(char[SIZE_NUM]));
} for(i = ; i < len_array; i++)
{
count = ; // 计数清零
count_num = ;
for(j = ; j <= num; j++)
{
for(k = ; k <= num; k++)
{
if(j + k == array_num[i])
{
sprintf(array_detail[i] + count_num, "(%d, %d)", j, k);
//printf("%s", array_detail[i] + count_num);
count_num++;
count++;
array_detail[i] = (char(*)[SIZE_NUM])realloc(array_detail[i], (count_num + ) * sizeof(char[SIZE_NUM]));
memset(array_detail[i] + count_num, 0x0, SIZE_NUM);
}
}
}
remember_num[i] = count;
} for(i = ; i < len_array; i ++)
{
printf("数字 %d 的个数是: %d\n", i + , remember_num[i]);
for(j = ; j < remember_num[i]; j++)
{
printf("%s ", array_detail[i] + j);
}
printf("\n");
} //释放内存
free(remember_num);
remember_num = NULL; free(array_num);
array_num = NULL; for(i = ; i < len_array; i++)
{
free(array_detail[i]);
array_detail[i] = NULL;
}
free(array_detail);
array_detail = NULL; return; }

错了好多次,终于改对了。

prob的更多相关文章

  1. Could not autowire. No beans of 'TbItemMapper' type found. less... (Ctrl+F1) Checks autowiring prob

    Intellij Idea开发工具在@Autowired或者@Resource注入XxxMapper接口时报如下错误: Could not autowire. No beans of 'TbItemM ...

  2. soj1022. Poor contestant Prob

    1022. Poor contestant Prob Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description As everyb ...

  3. NOIP 2011 Day 1 部分题解 (Prob#1 and Prob#2)

    Problem 1: 铺地毯 乍一看吓cry,地毯覆盖...好像是2-dims 线段树,刚开头就这么难,再一看,只要求求出一个点,果断水题,模拟即可.(注意从标号大的往小的枚举,只要有一块地毯符合要求 ...

  4. The `XXXX` target overrides the `HEADER_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-game-desktop/Pods-game-desktop.release.xcconfig'. This can lead to prob

    The `game-desktop [Release]` target overrides the `HEADER_SEARCH_PATHS` build setting defined in `Po ...

  5. 【AIM Tech Round 4 (Div. 2) D Prob】

    ·题目:D. Interactive LowerBound ·英文题,述大意:       有一个长度为n(n<=50000)的单链表,里面的元素是递增的.链表存储在一个数组里面,给出长度n.表 ...

  6. 1.1.5 PROB Friday the Thirteenth

    Friday the Thirteenth Is Friday the 13th really an unusual event? That is, does the 13th of the mont ...

  7. 1.1.4 PROB Greedy Gift Givers

    Greedy Gift Givers A group of NP (2 ≤ NP ≤ 10) uniquely named friends has decided to exchange gifts ...

  8. 1.1.1 PROB Your Ride Is Here

    === /* ID: luopengting PROG: ride LANG: C++ */ #include <iostream> #include <cstdio> #in ...

  9. XSY contest1586 proB

    题目 现在一圈n个花坛, 每次随机往一个花盆里种花, 一个花盆可以种多颗花, 假如一个花盆两边的花盆都有花, 那么他也将被种上花 问期望种满所有花盆要种几次 首先定义f(i)为放置了i个物品后完全覆盖 ...

随机推荐

  1. Javascript系列: Google Chrome调试js代码(zz)

    你 是怎么调试 JavaScript 程序的?最原始的方法是用 alert() 在页面上打印内容,稍微改进一点的方法是用 console.log() 在 JavaScript 控制台上输出内容.嗯~, ...

  2. Opencv step by step - 图像载入

    之前已经使用过图像载入了,这里再讲述一下其他的一些tip. 先来一次普通的载入: #include <cv.h> #include <highgui.h> int main(i ...

  3. SEO入门教程

    什么是SEO? SEO的中文名叫做搜索引擎优化,主要的作用是将网站的关键词优化到搜索引擎靠前的位置 其中关键词可以划分成以下这几类: 主关键词,长尾关键词,相关关键词 例如:主关键词:网页 长尾关键词 ...

  4. Bootstrap系列 -- 17. 复选框checkbox和单选择按钮radio

    Bootstrap框架中checkbox和radio有点特殊,Bootstrap针对他们做了一些特殊化处理,主要是checkbox和radio与label标签配合使用会出现一些小问题(最头痛的是对齐问 ...

  5. css平时写的时候注意的

    1.如果用absolute的时候一定要注意,bottom如果为)的话,一定要注意上一级的relative是否有height. 2.chrome浏览器,我们需要注意的是width包含了padding,但 ...

  6. [USACO 1.5.4]checker(水题重做——位运算(lowbit的应用))

    描述 检查一个如下的6 x 6的跳棋棋盘,有六个棋子被放置在棋盘上,使得每行.每列有且只有一个,每条对角线(包括两条主对角线的所有平行线)上至多有一个棋子. 0 1 2 3 4 5 6 ------- ...

  7. javascript继承(二)—创建对象的三种模式

    一.工厂模式 function createPerson(name,age){ var o = {}; o.name = name; o.age = age; o.sayHi = function() ...

  8. Daily Scrum – 1/6

    Meeting Minutes 确认修复了一个bug,即变方的: 分配了以后的任务: 确认将速度写入了用户的设置文件 Burndown     Progress   part 组员 今日工作 Time ...

  9. /WEB-INF/userManage.jsp(31,82) Unterminated ${ tag

    这个错误是说明${}少写了一半. Unterminated有这个的意思是你的jsp语法有错误

  10. Mvc多级Views目录 asp.net mvc4 路由重写及 修改view 的寻找视图的规则

    一般我们在mvc开发过程中,都会碰到这样的问题.页面总是写在Views文件夹下,而且还只能一个Controller的页面只能写在相应的以 Controller名命名的文件夹下.如果我们写到别处呢?那么 ...