17-题目1052:找x
来源:互联网 发布:烟台seo自动优化软件 编辑:程序博客网 时间:2024/05/18 12:03
http://ac.jobdu.com/problem.php?pid=1052
输入一个数n,然后输入n个数值各不相同,再输入一个值x,输出这个值在这个数组中的下标(从0开始,若不在数组中则输出-1)。
题目很简单
<span style="font-size:18px;">#include<stdio.h>#include<iostream>using namespace std;int main(){int n, x, i, flag = 0,arr[200];while (cin >> n){flag = 0;for (i = 0; i < n; i++)cin >> arr[i];cin >> x;for (i = 0; i < n; i++){if (x == arr[i]){cout << i << endl;flag = 1;break;}}if (flag == 0)cout << "-1" << endl;}return 0;}</span>
0 0
- 17-题目1052:找x
- 题目1052:找x
- 题目1052:找x
- 题目1052:找x
- 题目1052:找x
- 题目1052:找x
- 题目1052:找x
- 题目 1052 找x
- 题目1052:找x
- 题目1052:找x
- 题目1052:找x
- 题目17:找x
- 九度题目1052:找x
- 九度 题目1052:找x
- 【九度】题目1052:找x
- 九度OJ题目1052:找x
- 九度OJ题目1052:找x
- 题目1122: 找x
- 数据结构(三)
- crontab linux 定时任务不执行问题
- c#动态加载dll并调用dll中类的方法
- linkinFrame--用maven搭项目结构
- 关于mount nfs时-o nolock的问题
- 17-题目1052:找x
- Mysql的基础整理
- 《Linux优化之iptables防火墙处理及运维思想》
- 任务调度和异步执行器(Quartz篇)
- Android 6.0 运行时权限处理完全解析
- 二叉树的遍历(C++)版
- Diksam代码阅读(4)——创建编译器
- 24:打印月历题解
- umeng自动更新