prob
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的更多相关文章
- 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 ...
- soj1022. Poor contestant Prob
1022. Poor contestant Prob Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description As everyb ...
- NOIP 2011 Day 1 部分题解 (Prob#1 and Prob#2)
Problem 1: 铺地毯 乍一看吓cry,地毯覆盖...好像是2-dims 线段树,刚开头就这么难,再一看,只要求求出一个点,果断水题,模拟即可.(注意从标号大的往小的枚举,只要有一块地毯符合要求 ...
- 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 ...
- 【AIM Tech Round 4 (Div. 2) D Prob】
·题目:D. Interactive LowerBound ·英文题,述大意: 有一个长度为n(n<=50000)的单链表,里面的元素是递增的.链表存储在一个数组里面,给出长度n.表 ...
- 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 ...
- 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 ...
- 1.1.1 PROB Your Ride Is Here
=== /* ID: luopengting PROG: ride LANG: C++ */ #include <iostream> #include <cstdio> #in ...
- XSY contest1586 proB
题目 现在一圈n个花坛, 每次随机往一个花盆里种花, 一个花盆可以种多颗花, 假如一个花盆两边的花盆都有花, 那么他也将被种上花 问期望种满所有花盆要种几次 首先定义f(i)为放置了i个物品后完全覆盖 ...
随机推荐
- Expectation maximization - EM算法学习总结
原创博客,转载请注明出处 Leavingseason http://www.cnblogs.com/sylvanas2012/p/5053798.html EM框架是一种求解最大似然概率估计的方法.往 ...
- NetBios网络基础及编程
开始学习(算是复习)网络编程了,第一个就是局域网的netbios协议编程. 首先了解一下什么是netbios:IBM公司为PC-Network开发的一套网络标准.,NetBIOS最广泛的应用之一就是对 ...
- 使用Let’s Encrypt轻松配置https站点
使用Let's Encrypt轻松配置https站点 https不仅能提高网站安全,更是被搜索引擎纳入排名的因素之一. 2015年10月份,微博上偶然看到Let's Encrypt 推出了beta版, ...
- Ado.net 通用访问类
public class DbHelperSQL { private static string connString = ConfigurationManager.ConnectionStrings ...
- Spring学习(三)——Spring中的依赖注入的方式
[前面的话] Spring对我太重要了,做个关于web相关的项目都要使用Spring,每次去看Spring相关的知识,总是感觉一知半解,没有很好的系统去学习一下,现在抽点时间学习一下Spring.不知 ...
- Object C学习笔记13-Dictionary字典
通过Array数组和Set集合的学习和理解,可以想象得到Dictionary也分为两种情况了,那就是可变和不可变两种类型的.的确如此,在Object C中提供了两个字典类,分别为NSDictionar ...
- 自己留存:mysql full text 支持中文的一个设定
innodb_ft_min_token_size=1 ft_min_word_len=1
- 《TCP/IP详解卷1:协议》第19章 TCP的交互数据流-读书笔记
章节回顾: <TCP/IP详解卷1:协议>第1章 概述-读书笔记 <TCP/IP详解卷1:协议>第2章 链路层-读书笔记 <TCP/IP详解卷1:协议>第3章 IP ...
- PHP微信登錄(網頁授權)之後的獲取用戶的信息
//這部峯代碼是封裝的庫文件,<?php /** * Created by PhpStorm. * User: root * Date: 16-6-23 * Time: 下午3:29 */ cl ...
- 腾讯云CentOS7安装LNMP+wordpress
许多云主机都有学生优惠,于是我趁着现在大一买了个腾讯1元云主机+免费cn域名(高中生的话就别想了).鉴于我只知道用服务器安装博客,别的用途不了解,所以我就去安装wordpress. 而由于我看的教程有 ...