Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : 定義主控台應用程式的進入點。
- //
- #include "stdafx.h"
- #include<iostream>;
- using namespace std;
- int maxf(int *in,int n)
- {
- int max = in[0];
- for (int i = 0; i < n; i++)
- {
- if (in[i]>max)
- max = in[i];
- cout << "number " << i + 1 << " : ";
- cout << in[i] << endl;
- }
- return max;
- }
- void main()
- {
- int n;
- cout << "How maney number you want find:";
- while (cin >> n)
- {
- int *in = new int[n],max;
- for (int i = 0; i < n; i++)
- {
- cout << "number " << i + 1 << " : ";
- cin >> in[i];
- }
- cout << '\n';
- cout << "the maximum is " << maxf(in,n) << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement