#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. SQL Server表关联

    表关联:Hash.Nested Loops.Merge.这是实际算法,不是T-SQL中的inner/left/right/full/cross join.优化器会把这些T-SQL写法转换成上面的3种算 ...

  2. 记录mysql正在执行的SQL语句

    show variables like "general_log%"; SET GLOBAL general_log = 'ON';SET GLOBAL general_log = ...

  3. CentOS命令行向OSS上传文件或文件夹

    下载地址:https://helpcdn.aliyun.com/document_detail/50452.html?spm=a2c4g.11186623.4.2.KyQak3 百度云盘:https: ...

  4. MySQL 存储过程中分页

    MySQL数据库中,自定义存储过程查询表中的数据,带有分页功能.具体实例如下代码: 1 DROP PROCEDURE IF EXISTS `sampledb`.`proc_GetPagedDataSe ...

  5. BZOJ2084 [Poi2010]Antisymmetry Manachar

    题目传送门 - BZOJ2084 题解 对于一个0我们把它看作01,1看作10,然后只要原串中的某个子串可以通过这两个变换成为回文串就可以满足条件了. 对于转换过的串,Manachar随便弄几下就可以 ...

  6. C#基础:委托之Action<T>和Func<T>的用法

  7. MySQL高级02

    索引简介 索引(Index)是帮助MySQL高效获取数据的数据结构.可以得到索引的本质:索引是数据结构.你可以简单理解为“排好序的快速查找数据结构”. 在数据之外,数据库系统还维护着满足特定查找算法的 ...

  8. SSH框架学习------struts2前后台传值(二)

    struts2的Action类一般都会继承(extends)ActionSupport类(Action类,即实现action的类)1.前传后:jsp里<input type="text ...

  9. php 图形用户界面GUI 开发

    php 图形用户界面GUI 开发 一.下载指定系统扩展 1 2 http://pecl.php.net/package/ui http://pecl.php.net/package/ui/2.0.0/ ...

  10. HTML文本结构及常用标签

    一.什么是HTML? HTML:超文本标签语言 (Hyper Text Markup Language) www万维网的描述性语言. XHTML指可扩展超文本标记语言(标识语言)(EXtensible ...