Created
March 5, 2013 00:44
-
-
Save taishi41228/5087068 to your computer and use it in GitHub Desktop.
適当なプログラム ref: http://qiita.com/items/8c60e39d48473e5570aa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int findInt (int a[], int n, int x){ | |
int i; | |
for (i=0; i < n; i++) { | |
if (a[i] == x) { | |
return 1; | |
} else { | |
return 0; | |
} | |
} | |
return -1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void printMaxInt (int a[], int n); | |
void printArray (int a[], int n); | |
int findInt (int a[], int n, int x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void printArray (int a[], int n){ | |
int i; | |
for (i=0 ; i<n; i++) { | |
printf("x[%d] = %d \n",i,a[i]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void printMaxInt (int a[], int n) { | |
int max = 0, i; | |
for (i = 0; i < n; i++) { | |
if (max < a[i]) { | |
max = a[i]; | |
} | |
} | |
printf("%d\n", max); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment