#include <iostream>

using namespace std;

void matching(int a[],int b[],int N)

{

int i=0;

while(i<N)

{

int j=0;

while(j<N)

{

if(a[i]==b[j])

{

cout<<"a["<<i<<"]"<<match<<"b["<<j<<"]"<<endl;

break;

}

j++;

}

i++;

}

cout<<endl;

}

int main()

{

int a[]={1,2,3,4,5,6,7,8,9,10};
  int b[]={1,3,7,4,2,5,6,10,8,9};

int N=sizeof(a)/sizeof(int);

matching(a,b,N);

system("pause");

return 0;

}

总结:while先运行一次,再i,j自增,再判断。不管怎样,都会运行一次循环语句。

编程菜鸟的日记-初学尝试编程-寻找等长数组A与B(所含元素相同,顺序不同)相匹配的元素即a[i]=b[j]的更多相关文章

  1. 编程菜鸟的日记-初学尝试编程-寻找2到n之间的素数并输出

    //输入一个整数n,输出2到n之间的具体素数值 #include <iostream> #include <algorithm> #include <cmath> ...

  2. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习9

    #include <iostream> #include <fstream> #include <cstdlib> #include <string> ...

  3. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习8

    #include <iostream> #include <fstream> #include <cstdlib> const int SIZE=20; using ...

  4. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习7

    #include <iostream> #include <string> #include <cctype> using namespace std; int m ...

  5. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习6

    #include <iostream> #include <string> using namespace std; const int MSIZE=100; struct j ...

  6. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习5

    #include <iostream> using namespace std; const double N1=35000; const int N2=15000; const int ...

  7. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习4

    #include <iostream> using namespace std; const int strsize=30; const int BOPSIZE=5; void showm ...

  8. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习3

    #include <iostream> using namespace std; void showmenu(void) { cout<<"Please enter ...

  9. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习2

    #include <iostream> #include <cctype> using namespace std; const int MAXSIZE=10; int mai ...

随机推荐

  1. shell 处理文件脚本

    [root@centos-6 ~]# cat info_file.txt lys:28:shanxi zhy:28:shanxi [root@centos-6 ~]# cat info_file2.t ...

  2. SpringMVC - 1.快速入门

    1. HelloWorld 步骤: 加入 jar 包 mons-logging-1.1.3.jar spring-aop-4.0.0.RELEASE.jar spring-beans-4.0.0.RE ...

  3. 494. Target Sum

    You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symb ...

  4. (转载)dotnet core 中文乱码 codepages

    引子 转载自:http://www.jianshu.com/p/1c9c59c5749a 参考:.Net Core 控制台输出中文乱码 上文中我查阅了一些cli的源码, 闲来无事就继续翻代码, 冥冥之 ...

  5. python多线程之t.setDaemon(True) 和 t.join()

    0.目录 1.参考2.结论    (1)通过 t.setDaemon(True) 将子线程设置为守护进程(默认False),主线程代码执行完毕后,python程序退出,无需理会守护子线程的状态.    ...

  6. 【译】你应该了解的JavaScript数组方法

    让我们来做一个大胆的声明:for循环通常是无用的,而且还导致代码难以理解.当涉及迭代数组.查找元素.或对其排序或者你想到的任何东西,都可能有一个你可以使用的数组方法. 然而,尽管这些方法很有用,但是其 ...

  7. ui-router实现返回上一页功能

    angular.module('ConsoleUIApp', ['ui.router','ui.bootstrap']) .config(function ($stateProvider, $urlR ...

  8. centos中less翻页查询的用法

    用法实例: cat 21342.log | less

  9. go-关于指针和地址

    经常会见到: p . *p , &p 三个符号  p是一个指针变量的名字,表示此指针变量指向的内存地址,如果使用%p来输出的话,它将是一个16进制数. 而*p表示此指针指向的内存地址中存放的内 ...

  10. Codeforces 1000G Two-Paths 树形动态规划 LCA

    原文链接https://www.cnblogs.com/zhouzhendong/p/9246484.html 题目传送门 - Codeforces 1000G Two-Paths 题意 给定一棵有 ...