C程序:定义宏打印某位域共有多少位
#include <stdio.h>
#define bits(p, d) { \
int _tmp=p->d, _bits=0; \
for (p->d=1; p->d; p->d<<=1) \
_bits++; \
p->d=_tmp; \
printf("%s->%s has %d bits", #p, #d, _bits); \
}
typedef struct _s{
int a:4;
} S;
int main()
{
S tmp, *s = &tmp;
bits(s,a);
}
/* 输出: s->a has 4 bits */
相关文档:
输出斐波那契数列前N个合数,四个一行,N由使用者输入,介于10到30之间。
#include<stdio.h>
#include<math.h>
int fab(int);
int judge(int);
int main()
{
int a[30]={0};
int i,n,t=0;
do
{
printf("Input the number\n");
scanf("%d",&n);
}
while(n>3 ......
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.spri ......
/*
思路:递归算法
从开始往后递增地写数字,当前从now值开始,存储的位置从cur开始,
则显然加上,now..n,都是新的组合数,对于每一个,{ 输出之,然后递归,处理 _c(n, cur+1, a, i+1) }
*/
/* 输出1,2,3,..,n的组合数 */
#include <stdio.h>
#include <assert.h>
#include <malloc.h>
void ......
/*
思路:递归算法
前0..cur-1位置上已经排好,当前cur位置取一个和前面都不一样的,然后递归处理后面的。
*/
/* 输出1,2,3,..,n的排列数 */
#include <stdio.h>
#include <assert.h>
#include <malloc.h>
void p(int n)
{
extern void _p(int n, int cur, int *a);
int *a;
a = ......