• 2.找出单独出现的数字


    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main()
    {
        // please write your code here
        int result = 0;
        int input;
        while(cin >> input){
            result = result^input;
        }
        cout << result << endl;
        return 0;
    }
    #include <bits/stdc++.h>
    
    using namespace std;
    
    int main()
    {
        // please write your code here
        //数据定义
        int count = 0;//数组有效长度
        int* inter  = new int[20];
        //获取数据
        
        int a = 0;
        int i = 0;
        while (cin >>a)
        {
            inter[i++] = a;
            count++;
        }
    
        ////找出整数数组中不同的数字
        for (int i = 0; i < count; i++)
        {
            for (int j = 0; j < count; j++)
            {
                if (i != j)
                {
                    //找到相同的立马回去,找inter的下一个元素的相同值
                    if(inter[i] == inter[j])
                        break;
    
                    //找到最后没找到
                    else if (j == count - 1)
                    {
                        cout << inter[i] << endl;
                    }
    
                }
                //最后一个是不同的
                else if (i == j && i == count -1)
                {
                    cout << inter[i]<<endl;
                }
            }
        }
    
        return 0;
    }
  • 相关阅读:
    实验五
    实验一
    实验四
    实验三
    实验8 SQLite数据库操作
    实验7 BindService模拟通信
    实验6 在应用程序中播放音频和视频
    实验5 数独游戏界面设计
    实验4 颜色、字符串资源的使用
    实验五 存储管理实验
  • 原文地址:https://www.cnblogs.com/sethnie/p/11298854.html
Copyright © 2020-2023  润新知