| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2397 人关注过本帖
标题:[讨论]电话号码问题
只看楼主 加入收藏
我不是郭靖
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:494
专家分:6
注 册:2006-10-4
收藏
得分:0 
512k内存是指什么?
变量内存?
代码内存?
运行内存?

还有
这些内存怎么测,有谁知道?

2006-12-03 22:17
sneil
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-9-20
收藏
得分:0 
#include"stdio.h"
#include"string.h"
struct str
{
    char *ch;
    long int m;
}phone[1000000];
main()
{
    char *a,*number;
    char b[1000000][21],c[1000000][21],x[1000000][21];
    long int i,n=0,flag=0,d[10000000],e[1000000],j=0,k=0,y,z=1,temp;
    while((scanf("%s",number))!=EOF)
    {
        strcpy(x[n],number);
        for(i=0;i<20;i++)
        {
            if(number[i]=='A'||number[i]=='B'||number[i]=='C')
                x[y][i]='2';
            if(number[i]=='D'||number[i]=='E'||number[i]=='F')
                x[y][i]='3';
            if(number[i]=='G'||number[i]=='H'||number[i]=='I')
                x[y][i]='4';
            if(number[i]=='J'||number[i]=='K'||number[i]=='L')
                x[y][i]='5';
            if(number[i]=='M'||number[i]=='N'||number[i]=='O')
                x[y][i]='6';
            if(number[i]=='P'||number[i]=='R'||number[i]=='S')
                x[y][i]='7';
            if(number[i]=='T'||number[i]=='U'||number[i]=='V')
                x[y][i]='8';
            if(number[i]=='W'||number[i]=='X'||number[i]=='Y')
                x[y][i]='9';
        }
        for(i=0;i<20;i++)
        {
            if(x[y][i]!='-')
            {
                x[y][n]=x[y][i];
            }
        }
        y++;
    }
    for(j=0;j<y;j++)
    {
        for(i=0;i<20;i++)
        {
        
            if(x[j][0]!='3'||x[j][0]!='6'||x[j][0]!='D'||x[j][0]!='E'||x[j][0]!='F'||x[j][0]!='M'||x[j][0]!='N'||x[j][0]!='O')
            {
                strcpy(b[flag],x[j]);
                d[flag]=j;
                flag++;
                break;
            }
            if(a[i]=='Q'||a[i]=='Z')
            {
                strcpy(b[flag],x[j]);
                d[flag]=i;
                flag++;
                break;
            }
        }
    }
    for(i=0;i<y;i++)
    {
        if(i!=d[flag])
        {
            for(j=0&&j!=i;j<y;j++)
            {
                if(strcmp(x[i],x[j])==0)//记录重复的串
                {   
                    k=i;
                    z++;
                    e[k]==z;
                    strcpy(c[k],x[i]);
                }
                else
                    continue;   
            }
        }
    }
    printf("Error:\n");
    if(flag==0)
        printf("Not found.\n");
    else
        for(i=0;i<flag;i++)
            printf("%s\n",b[i]);
    printf("Duplication:\n");
    if(z==1)
        printf("Not found.\n");
    else
        
            printf("%s %ld\n",);
   
} 我写了一个,还没优化。而且在保存重复字符串和其重复次数那儿写不下去了。
2014-09-20 02:13
sneil
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2014-9-20
收藏
得分:0 
#include"stdio.h"
#include"string.h"
main()
{
    char *a,*number;
    char b[1000000][21],c[1000000][21],x[1000000][21];
    long int i,n=0,flag=0,d[10000000],e[1000000],j=0,k=0,y,z=1;
    while((scanf("%s",number))!=EOF)
    {
        strcpy(x[y],number);
        for(i=0;i<20;i++)
        {
            if(number[i]=='A'||number[i]=='B'||number[i]=='C')
                x[y][i]='2';
            if(number[i]=='D'||number[i]=='E'||number[i]=='F')
                x[y][i]='3';
            if(number[i]=='G'||number[i]=='H'||number[i]=='I')
                x[y][i]='4';
            if(number[i]=='J'||number[i]=='K'||number[i]=='L')
                x[y][i]='5';
            if(number[i]=='M'||number[i]=='N'||number[i]=='O')
                x[y][i]='6';
            if(number[i]=='P'||number[i]=='R'||number[i]=='S')
                x[y][i]='7';
            if(number[i]=='T'||number[i]=='U'||number[i]=='V')
                x[y][i]='8';
            if(number[i]=='W'||number[i]=='X'||number[i]=='Y')
                x[y][i]='9';
        }
        for(i=0;i<20;i++)
        {
            if(x[y][i]!='-')
            {
                x[y][n]=x[y][i];
                n++;
            }
        }
        y++;
    }
    for(j=0;j<y;j++)
    {
        for(i=0;i<20;i++)
        {
        
            if(x[j][0]!='3'||x[j][0]!='6'||a[i]=='Q'||a[i]=='Z')
            {
                strcpy(b[flag],x[j]);
                d[flag]=j;
                flag++;
                break;
            }
        }
    }
    for(i=0;i<y;i++)
    {
        if(i!=d[flag])
        {
            for(j=0&&j!=i;j<y;j++)
            {
                if(strcmp(x[i],x[j])==0)
                {   
                    z++;
                }
                else
                    continue;   
            }
        }
        if(z!=1)
        {
            e[k]=z;
            strcpy(c[k],x[i]);
            k++;
        }
    }
    printf("Error:\n");
    if(flag==0)
        printf("Not found.\n");
    else
        for(i=0;i<flag;i++)
        {
            for(j=0;j<=7;j++)
            {
                printf("%c",b[i]);
            }
            printf("\n");
        }
    printf("Duplication:\n");
    if(k==0)
        printf("Not found.\n");
    else
        for(i=0;i<k;i++)
        {
            printf("%s %ld\n",c[i],e[i]);
        }
   
} 这个题我写出来,感觉算法应该没错啊,但就是程序停止工作咋回事儿啊?求大神
2014-09-21 15:34
快速回复:[讨论]电话号码问题
数据加载中...
 
   



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

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