易截截图软件、单文件、免安装、纯绿色、仅160KB

C队列 输出杨辉三角


也是中软笔试的算法题,当时并不知道叫杨辉三角,唉。N年不用了,还得再拾起,为了那个梦。
#include <stdio.h>
void main()
{
    int a[50][50];
    int i,j,n;
    printf("Please input Number:");
    scanf("%d",&n);
    for (i=0;i<n;i++)
    {
        for (j=0;j<=i;j++)
        {
            if (j==0 ||j==i)
                a[i][j]=1;
            else
                a[i][j]=a[i-1][j-1]+a[i-1][j];
            printf("%5d",a[i][j]);
        }
        printf("\n");
    }
    getch();
}
/*TC 2.0测试*/
#define size 100
#define true 1
   #define false 0
    typedef int elemtype;
    typedef struct queue
     {
       elemtype element[size];
      int front;
       int rear;}queue;/*jie gou ti*/
    void initqueue(queue*q)
    {
       q->front=q->rear=0;}/*chu shi hua*/
    int enqueue(queue*q,int x)
    {
       if((q->rear+1)%size==q->front)
        return(false);
         q->element[q->rear]=x;
          q->rear=(q->rear+1)%size;
      &nb


相关文档:

又是3只C。。。= =

1.写出两个函数,分别求两个整数的最大公约数和最小公倍数,用主函数调用这两个函数,并输出结果。两个整数由键盘输入。
#include<stdio.h>
int gcd(int,int);
int lcm(int,int);
int gcd(int m,int n)
{
if(m%n==0)
return n;
else
return gcd(n,m%n);
}
int lcm(int m,int n)
{
return m*n/(gc ......

我的C实践(8):字搜索

  字搜索就搜索一个数中具有某些特征的位。实现如下:
/* wsearch.c:字搜索 */
/* 从左边寻找第一个0字节:第0(1,2,3)个字节是0时,返回0(1,2,3),否则返回4 */
int zbytel(unsigned x){
if((x>>24)==0) return 0;
else if((x & 0x00ff0000)==0) return 1;
else if((x & 0x0000ff00)==0) r ......

我的C实践(9):位和字节的重排

  位和字节的重排在密码学算法中有广泛的应用。
/* rearran.c:位和字节的重排 */
/* 位反转:以字的中心为对称点进行位反射
例如: abcd efgh ijkl mnop ABCD EFGH IJKL MNOP
位反转:PONM LKJI HGFE DCBA ponm lkji hgfe dcba */
unsigned rev(unsigned x){
/* 交换相邻的单个位 */
x=(x & 0x5 ......

自己动手写一个判断网址合法的C\C++的正则表达式程序

#include<stdio.h>
#include<regex.h>
int main(int argc, char** argv)
{
if(IsLegalPage("http://www.baidu.com"))
printf("该网页合法\n");
else printf("该网页不合法!!!\n");
return 0;
}
/* 函数说明:判断网页是否合法
* 输入参数:需要判断的网 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号