Skip to content

Instantly share code, notes, and snippets.

@pbondoer
Created September 5, 2017 10:32
Show Gist options
  • Save pbondoer/b78c51ccbdbf31463c9cfc612902b726 to your computer and use it in GitHub Desktop.
Save pbondoer/b78c51ccbdbf31463c9cfc612902b726 to your computer and use it in GitHub Desktop.
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pbondoer <pierre@bondoer.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/09/05 12:25:06 by pbondoer #+# #+# */
/* Updated: 2017/09/05 12:31:59 by pbondoer ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
int main(int argc, char **argv) {
int a[5] = { 1, 2, 3, 5, 7 };
int b[5] = { 2, 4, 5, 6, 7 };
int i = 0;
int j = 0;
int n = 5;
while (i < n && j < n)
{
if (a[i] > b[j])
j++;
else if (a[i] < b[j])
i++;
else
{
printf("%d ", a[i]);
i++;
j++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment