输入n个数,找出第一个只出现一次的数,输出它。

如果没有,输出none。

思路:

将输入的数值作为HashTable的数组下标即可。

 #include<cstdio>
int a[], hashTable[]={};
int main(){
int n;
scanf("%d", &n);
for(int i=;i<n;i++){
scanf("%d",&a[i]);
hashTable[a[i]]++;
}
int ans=-;
for(int i=;i<n;i++){//遍历n即可
if(hashTable[a[i]]==){
ans=a[i];
break;
}
}
if(ans==-) printf("None");
else printf("%d\n", ans);
return ;
}

A1041的更多相关文章

  1. A1041. Be Unique

    Being unique is so important to people on Mars that even their lottery is designed in a unique way. ...

  2. A1041 Be Unique (20 分)

    一.技术总结 这题在思考的时候遇见了,不知道怎么处理输入顺序问题,虽然有记录每个的次数,事后再反过来需要出现一次的且在第一次出现, 这时我们其实可以使用另一个数组用来存储输入顺序的字符,然后再用另一个 ...

  3. PAT甲级——A1041 Be Unique

    Being unique is so important to people on Mars that even their lottery is designed in a unique way. ...

  4. 1041 Be Unique (20 分)

    1041 Be Unique (20 分) Being unique is so important to people on Mars that even their lottery is desi ...

  5. PAT_A1041#Be Unique

    Source: PAT A1041 Be Unique (20 分) Description: Being unique is so important to people on Mars that ...

  6. PAT甲级题解分类byZlc

    专题一  字符串处理 A1001 Format(20) #include<cstdio> int main () { ]; int a,b,sum; scanf ("%d %d& ...

随机推荐

  1. DevExpress源码编译总结 z

    本篇文章内容包括基础知识(GAC.程序集强签名.友元程序集).编译过程.注册GAC.添加工具箱.多语言支持.运行时和设计时调试 源码地址 链接:http://pan.baidu.com/s/1eQm1 ...

  2. 【Leetcode】【Medium】Triangle

    Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent n ...

  3. Python学习---重点模块之configparse

    configparse模块常用于生成和修改常见的配置文档 生成配置模块:用字典写 import configparser config = configparser.ConfigParser() co ...

  4. Spark Executor内幕彻底解密:Executor工作原理图、ExecutorBackend注册源码解密、Executor实例化内幕、Executor具体工作内幕

    本课主题 Spark Executor 工作原理图 ExecutorBackend 注册源码鉴赏和 Executor 实例化内幕 Executor 具体是如何工作的 Spark Executor 工作 ...

  5. Oracle RAC和SCAN同时对外提供服务的配制方法

    1,  tnsnames.ora on two nodes:RACTEST =  (DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = racsca ...

  6. 浅谈SAP Cloud for Sales 自动化

    在Jerry还在本科进行计算机理论知识学习时,我曾经把软件开发里的质量工程师(Quality Engineer)理解成是每天只是简单地做着运行开发人员编写好的软件,如果发现问题,通知开发人员去修改这种 ...

  7. 薄弱的交互页面之新浪微博到博客的储存型xss漏洞

    首先分享一片博文到微博,然后 在微博评论xss code 最后回到博客点击举报就触发xss了 点击举报 Xss之2 首先还是分享一片博文到微博,然后评论xsscode 回到我的博客个人中心,查看评论 ...

  8. WEB开发的jsp例子标签库(jstl)的使用

    <!-- e1 --> <%@ page language="java" contentType="text/html; charset=UTF-8&q ...

  9. PHP 字符串补0

    转自:https://www.cnblogs.com/bluebirds/archive/2016/11/22/6091099.html#undefined 概述:项目中经常会使用到在一串编码左边.右 ...

  10. Linear Search

    Search I You are given a sequence of n integers S and a sequence of different q integers T. Write a ...