| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4391 人关注过本帖
标题:关于简易语法高亮(已有第三版,免费)
只看楼主 加入收藏
lnhaing
Rank: 1
等 级:新手上路
帖 子:111
专家分:0
注 册:2008-1-30
收藏
得分:0 
加油!

我来自偶然! bitter C
2008-04-24 16:33
zhaoyg
Rank: 1
等 级:新手上路
帖 子:328
专家分:0
注 册:2006-8-28
收藏
得分:0 
以下是引用 雨中飛燕 在 2008-4-24 16:04 的发言:
自动缩进貌似在这代码的基础上做不难。。。偶今晚试试看。。。。

那就太好了。
不过希望能把代码能写的易懂些,
说实话,我这个建议是从自己的角度出发的,因为我对我的那个夭折的缩排程序仍然耿耿于怀,所以想从LZ这里得到些方法。希望我这样做不算自私。

麻雀飞上枝头变凤凰,而菜鸟的我飞上枝头却感冒了,为什么我的脑袋如此的不管用呢。
2008-04-24 18:13
zhaoyg
Rank: 1
等 级:新手上路
帖 子:328
专家分:0
注 册:2006-8-28
收藏
得分:0 
对了,为什么LZ写的那些小程序都是用C++写的呢??

麻雀飞上枝头变凤凰,而菜鸟的我飞上枝头却感冒了,为什么我的脑袋如此的不管用呢。
2008-04-24 18:17
雨中飛燕
Rank: 1
等 级:新手上路
帖 子:765
专家分:0
注 册:2007-10-13
收藏
得分:0 
因为纯C的程序很恶心,纯C++的话,有的东西自己控制起来又不方便
算法部分是C/C++的混合体(能轻易移植),
界面是用的MFC,MFC就不管它移不移植了,
反正界面代码量很少,没什么价值

" border="0" />[color=white]
2008-04-24 18:29
雨中飛燕
Rank: 1
等 级:新手上路
帖 子:765
专家分:0
注 册:2007-10-13
收藏
得分:0 
昨晚和今天早上都想了一下,要考虑的东西还不少,
麻烦在于本身不规范的,喜欢省略大括号的代码,
还有一些特殊约定的问题

假如每个代码都不省略大括号地写,那倒真的简单很多
现在偶还没开始动手,偶还是想先考虑清楚

" border="0" />[color=white]
2008-04-25 14:07
死了都要C
Rank: 4
来 自:四川成都
等 级:贵宾
威 望:13
帖 子:1582
专家分:116
注 册:2006-12-7
收藏
得分:0 
[bo]以下是引用 [un]雨中飛燕[/un] 在 24/4/2008 18:29 的发言:[/bo]

因为纯C的程序很恶心
http://blog. ...



这是什么意思``为什么这样说呢?

女施主``我给你``送茶来了```师太``你就从了老衲吧``
代码本天成~~~妙头偶得之```
2008-04-25 18:55
localc
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2008-4-25
收藏
得分:0 
翻译下开头那段代码


 #include <stdio.h>

int main()
{
    int i;
    const char *s="计铡诣窒瞪修势裸绸解\10\0 晾默?|";
   
   
    for( i=0;  putchar(s[i]+i%3) ; i++)
               ;
               
               
    for(i=0   ; putchar(s[i]+i%3) ;  i==13?i+=10:i++ )
                ;
               
               
    getchar();
    return 0;
}
2008-04-25 23:21
卧龙孔明
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:59
帖 子:3872
专家分:684
注 册:2006-10-13
收藏
得分:0 
试试
#include<stdio.h>
#include<string.h>

struct
{
        int x, y;
        int p;
} line[20000];
int map[52][52];
int yes[4][52][52];

int main(void)
{
    int i, j, k;
    char tmpchar[6];
   
    int x, y, x1, y1, x2, y2;
   
    int to[4][2]={{1,3},{0,2},{1,3},{0,2}};
    char word[4][6]={"east", "south", "west", "north"};
   
   
   
    while(scanf("%d%d", &x, &y),(x!=0 && y!=0))
    {
        int point=0, now=1;
        int flag=0;
        memset(map, 0, sizeof(map));
        memset(yes, 0, sizeof(yes));
        for(i=1; i<=x; i++)
        {
            for(j=1; j<=y; j++)
            {
                scanf("%d", &map[i][j]);
                for(k=0; k<4; k++)
                {
                    yes[k][i][j]=map[i][j];
                }
            }
        }
        scanf("%d%d%d%d%s", &x1, &y1, &x2, &y2, tmpchar);
        if(x1==x2 && y1==y2)
        {
            printf("0\n");
            continue;
        }
        line[point].x = x1;
        line[point].y = y1;
        for(i=0; i<4; i++)
        {
            if(strcmp(word[i], tmpchar) == 0)
            {
                line[point].p = i;
                break;
            }
        }
        yes[line[point].p][x1][y1]=1;
        while(point<now && now<19000)
        {
            for(i=0; i<2; i++)
            {
                if(!yes[to[line[point].p][i]][line[point].x][line[point].y])
                {
                    line[now] = line[point];
                    line[now].p = to[line[point].p][i];
                    yes[line[now].p][line[point].x][line[point].y] = yes[line[point].p][line[point].x][line[point].y]+1;
                    now++;
                }
            }
            switch(line[point].p)
            {
                case 0:
                    for(i=1+line[point].y, k=0; k<4 && i<y && (!map[line[point].x][i+1]) && (!map[line[point].x+1][i+1]); i++,k++)
                    {
                        if(!yes[line[point].p][line[point].x][i])
                        {
                            line[now] = line[point];
                            line[now].y = i;
                            yes[line[point].p][line[point].x][i] = yes[line[point].p][line[point].x][line[point].y]+1;
                            if(line[now].x == x2 && line[now].y == y2)
                            {
                                flag=1;
                                goto finish;
                            }
                            now++;
                        }
                    }
                    break;
                case 1:
                    for(i=1+line[point].x, k=0; k<4 &&  i<x && (!map[i+1][line[point].y]) && (!map[i+1][line[point].y+1]); i++,k++)
                    {
                        if(!yes[line[point].p][i][line[point].y])
                        {
                            line[now] = line[point];
                            line[now].x = i;
                            yes[line[point].p][i][line[point].y] = yes[line[point].p][line[point].x][line[point].y]+1;
                            if(line[now].x == x2 && line[now].y == y2)
                            {
                                flag=1;
                                goto finish;
                            }
                            now++;
                        }
                    }
                    break;
                case 2:
                    for(i=line[point].y-1, k=0; k<4 && i>0 && (!map[line[point].x][i]) && (!map[line[point].x+1][i]); i--,k++)
                    {
                        if(!yes[line[point].p][line[point].x][i])
                        {
                            line[now] = line[point];
                            line[now].y = i;
                            yes[line[point].p][line[point].x][i] = yes[line[point].p][line[point].x][line[point].y]+1;
                            if(line[now].x == x2 && line[now].y == y2)
                            {
                                flag=1;
                                goto finish;
                            }
                            now++;
                        }
                    }
                    break;
                case 3:
                    for(i=line[point].x-1, k=0; k<4 && i>0 && (!map[i][line[point].y]) && (!map[i][line[point].y+1]); i--,k++)
                    {
                        if(!yes[line[point].p][i][line[point].y])
                        {
                            line[now] = line[point];
                            line[now].x = i;
                            yes[line[point].p][i][line[point].y] = yes[line[point].p][line[point].x][line[point].y]+1;
                            if(line[now].x == x2 && line[now].y == y2)
                            {
                                flag=1;
                                goto finish;
                            }
                            now++;
                        }
                    }
                    break;
            } /* End of switch*/
            
point++;
        }
        finish:
                if(flag)
                {
                    printf("%d\n", yes[line[now].p][line[now].x][line[now].y]-1);
                }
                else
               
{
                    printf("-1\n");
                }
    }
    return 0;
}

My Blog: www.aiexp.info
虽然我的路是从这里开始的,但是这里不再是乐土.感谢曾经影响过,引导过,帮助过我的董凯,飞燕,leeco,starwing,Rockcarry,soft_wind等等等等.别了,BCCN.
2008-04-25 23:24
卧龙孔明
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:59
帖 子:3872
专家分:684
注 册:2006-10-13
收藏
得分:0 
有一些问题,例如string.h和stdio.h颜色不一样,还有map变量
#include<stdio.h>
#include<string.h>
struct
{
        int x, y;
        int p;
} line[20000];
int map[52][52];
int yes[4][52][52];
int main(void)
{
    int i, j, k;
    char tmpchar[6];
   
    int x, y, x1, y1, x2, y2;
   
    int to[4][2]={{1,3},{0,2},{1,3},{0,2}};
    char word[4][6]={"east", "south", "west", "north"};
   
   
   
    while(scanf("%d%d", &x, &y),(x!=0 && y!=0))
    {
        int point=0, now=1;
        int flag=0;
        memset(map, 0, sizeof(map));
        memset(yes, 0, sizeof(yes));
        for(i=1; i<=x; i++)
        {
            for(j=1; j<=y; j++)
            {
                scanf("%d", &map[i][j]);
                for(k=0; k<4; k++)
                {
                    yes[k][i][j]=map[i][j];
                }
            }
        }
        scanf("%d%d%d%d%s", &x1, &y1, &x2, &y2, tmpchar);
        if(x1==x2 && y1==y2)
        {
            printf("0\n");
            continue;
        }
        line[point].x = x1;
        line[point].y = y1;
        for(i=0; i<4; i++)
        {
            if(strcmp(word[i], tmpchar) == 0)
            {
                line[point].p = i;
                break;
            }
        }
        yes[line[point].p][x1][y1]=1;
        while(point<now && now<19000)
        {
            for(i=0; i<2; i++)
            {
                if(!yes[to[line[point].p][i]][line[point].x][line[point].y])
                {
                    line[now] = line[point];
                    line[now].p = to[line[point].p][i];
                    yes[line[now].p][line[point].x][line[point].y] = yes[line[point].p][line[point].x][line[point].y]+1;
                    now++;
                }
            }
            switch(line[point].p)
            {
                case 0:
                    for(i=1+line[point].y, k=0; k<4 && i<y && (!map[line[point].x][i+1]) && (!map[line[point].x+1][i+1]); i++,k++)
                    {
                        if(!yes[line[point].p][line[point].x][i])
                        {
                            line[now] = line[point];
                            line[now].y = i;
                            yes[line[point].p][line[point].x][i] = yes[line[point].p][line[point].x][line[point].y]+1;
                            if(line[now].x == x2 && line[now].y == y2)
                            {
                                flag=1;
                                goto finish;
                            }
                            now++;
                        }
                    }
                    break;
                case 1:
                    for(i=1+line[point].x, k=0; k<4 &&  i<x && (!map[i+1][line[point].y]) && (!map[i+1][line[point].y+1]); i++,k++)
                    {
                        if(!yes[line[point].p][i][line[point].y])
                        {
                            line[now] = line[point];
                            line[now].x = i;
                            yes[line[point].p][i][line[point].y] = yes[line[point].p][line[point].x][line[point].y]+1;
                            if(line[now].x == x2 && line[now].y == y2)
                            {
                                flag=1;
                                goto finish;
                            }
                            now++;
                        }
                    }
                    break;
                case 2:
                    for(i=line[point].y-1, k=0; k<4 && i>0 && (!map[line[point].x][i]) && (!map[line[point].x+1][i]); i--,k++)
                    {
                        if(!yes[line[point].p][line[point].x][i])
                        {
                            line[now] = line[point];
                            line[now].y = i;
                            yes[line[point].p][line[point].x][i] = yes[line[point].p][line[point].x][line[point].y]+1;
                            if(line[now].x == x2 && line[now].y == y2)
                            {
                                flag=1;
                                goto finish;
                            }
                            now++;
                        }
                    }
                    break;
                case 3:
                    for(i=line[point].x-1, k=0; k<4 && i>0 && (!map[i][line[point].y]) && (!map[i][line[point].y+1]); i--,k++)
                    {
                        if(!yes[line[point].p][i][line[point].y])
                        {
                            line[now] = line[point];
                            line[now].x = i;
                            yes[line[point].p][i][line[point].y] = yes[line[point].p][line[point].x][line[point].y]+1;
                            if(line[now].x == x2 && line[now].y == y2)
                            {
                                flag=1;
                                goto finish;
                            }
                            now++;
                        }
                    }
                    break;
            } /* End of switch*/
            
point++;
        }
        finish:
                if(flag)
                {
                    printf("%d\n", yes[line[now].p][line[now].x][line[now].y]-1);
                }
                else
               
{
                    printf("-1\n");
                }
    }
    return 0;
}

My Blog: www.aiexp.info
虽然我的路是从这里开始的,但是这里不再是乐土.感谢曾经影响过,引导过,帮助过我的董凯,飞燕,leeco,starwing,Rockcarry,soft_wind等等等等.别了,BCCN.
2008-04-25 23:26
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
收藏
得分:0 
写的小软件肯定会有问题了..一般认为软件是改出来得...呵呵..stl和泛型..加全了应该就差不多了..哦也写过几个小程序都不是很满意 看来还是要多改改...

学习需要安静。。海盗要重新来过。。
2008-04-25 23:38
快速回复:关于简易语法高亮(已有第三版,免费)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.083494 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved