通讯录
来源:互联网 发布:多元线性回归模型矩阵 编辑:程序博客网 时间:2024/04/30 16:51
#include<stdio.h>
#include<string.h>
int main()
{
int n;
printf("请输入通讯录中的人的总数。");
scanf("%d",&n);
getchar();
printf("请输入通讯录中人的姓名和其对应的编号:\n");
int i;
char name[40][40];
int tell[40];
for(i=0; i<n; i++)
{
gets(name[i]);
scanf("%d",&tell[i]);
getchar();
}
int f,find[50];
printf("请输入需要查找的次数:\n");
scanf("%d",&f);
getchar();
char num=0,str[40][40];
for(i=0; i<f; i++)
{
gets(str[i]);
}
int l;
for(i=0; i<f; i++)
{
int len=strlen(str[i]);
int j=0,cnt=0;
for(l=0; l<n; l++)
{
cnt=0;
for(j=0; j<len; j++)
{
int k;
for(k=0; name[l][k]!='\0'; k++)
{
if(name[l][k]==str[i][j])
{
cnt++;
break;
}
}
}
if(cnt==len)
{
find[num]=l;
num++;
puts(name[l]);
printf("%d\n",tell[l]);
}
}
}
}
请输入通讯录中的人的总数。5
请输入通讯录中人的姓名和其对应的编号:
david
1232163
jim
62364
daniel
36476
wangqiang
3463426
zhangsan
6234563
请输入需要查找的次数:
2
jm
an
jim
62364
daniel
36476
wangqiang
3463426
zhangsan
6234563
Process returned 2 (0x2) execution time : 37.254 s
Press any key to continue.
#include<string.h>
int main()
{
int n;
printf("请输入通讯录中的人的总数。");
scanf("%d",&n);
getchar();
printf("请输入通讯录中人的姓名和其对应的编号:\n");
int i;
char name[40][40];
int tell[40];
for(i=0; i<n; i++)
{
gets(name[i]);
scanf("%d",&tell[i]);
getchar();
}
int f,find[50];
printf("请输入需要查找的次数:\n");
scanf("%d",&f);
getchar();
char num=0,str[40][40];
for(i=0; i<f; i++)
{
gets(str[i]);
}
int l;
for(i=0; i<f; i++)
{
int len=strlen(str[i]);
int j=0,cnt=0;
for(l=0; l<n; l++)
{
cnt=0;
for(j=0; j<len; j++)
{
int k;
for(k=0; name[l][k]!='\0'; k++)
{
if(name[l][k]==str[i][j])
{
cnt++;
break;
}
}
}
if(cnt==len)
{
find[num]=l;
num++;
puts(name[l]);
printf("%d\n",tell[l]);
}
}
}
}
请输入通讯录中的人的总数。5
请输入通讯录中人的姓名和其对应的编号:
david
1232163
jim
62364
daniel
36476
wangqiang
3463426
zhangsan
6234563
请输入需要查找的次数:
2
jm
an
jim
62364
daniel
36476
wangqiang
3463426
zhangsan
6234563
Process returned 2 (0x2) execution time : 37.254 s
Press any key to continue.
0 0
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- 通讯录
- iOS中多线程实现方案
- HashSet 集合 去重
- 指针和数组的区别
- [Spring]Annotation-based container configuration_AnotationBasis_01
- lintcode:Merge k Sorted Lists
- 通讯录
- Android API Guides---App Manifest <supports-gl-texture>
- asp.net中页面按钮回车默认执行 设置方法
- java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet
- javascript练习题(一)
- const和static和static const
- 数学的魅力,php的美丽。
- php真静态缓存 ob系统函数
- 算法(读书笔记):4.3最小生成树