博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
在有序的数列中查找某数,若该数在此数列中,则输出它所在的位置,否则输出no found
阅读量:4131 次
发布时间:2019-05-25

本文共 434 字,大约阅读时间需要 1 分钟。

#include<stdio.h>
#define N 10
void main()
{  int a[N];
   int num,i;
   char ch='n';
   printf("Input an array:\n");
   for(i=0;i<N;i++)
  scanf("%d",&a[i]);
   printf("Output the array:\n");
   for(i=0;i<N;i++)
  printf("%d ",a[i]);
   printf("\n");
   printf("Input a number:\n");
   scanf("%d",&num);
   printf("start finding\n");
   for(i=0;i<N;i++)
  if(num==a[i])
  {  ch='Y';
     printf("%d is the %dth number in the array\n",num,i+1);
  }
  if(ch=='n')
  printf("no found\n");
}

转载地址:http://frnvi.baihongyu.com/

你可能感兴趣的文章
SVN-无法查看log,提示Want to go offline,时间显示1970问题,error主要是 url中 有一层的中文进行了2次encode
查看>>
NGINX
查看>>
Qt文件夹选择对话框
查看>>
1062 Talent and Virtue (25 分)
查看>>
1061 Dating (20 分)
查看>>
1060 Are They Equal (25 分)
查看>>
83. Remove Duplicates from Sorted List(easy)
查看>>
88. Merge Sorted Array(easy)
查看>>
leetcode刷题191 位1的个数 Number of 1 Bits(简单) Python Java
查看>>
leetcode刷题198 打家劫舍 House Robber(简单) Python Java
查看>>
NG深度学习第一门课作业2 通过一个隐藏层的神经网络来做平面数据的分类
查看>>
leetcode刷题234 回文链表 Palindrome Linked List(简单) Python Java
查看>>
NG深度学习第二门课作业1-1 深度学习的实践
查看>>
Ubuntu下安装Qt
查看>>
Qt札记
查看>>
我的vimrc和gvimrc配置
查看>>
hdu 4280
查看>>
禁止使用类的copy构造函数和赋值操作符
查看>>
C++学习路线
查看>>
私有构造函数
查看>>