编写一下这个几个程序,不用标写注释,每个程序前面都要标清楚题号 9.1~9.3
9.1
#include <iostream>
using namespace std;
const size = 10;
void findmax(int* a, int n, int &pk);
int main()
{
int a[size];
int n = 0;
cout < "plsease input " << size << "datas:\n";
for (int i = 0; i < size; i++)
{
cin >> a[i];
}
findmax(a, size, n);
cout << "the maximum is " << a[n] << endl << "It's index is " << n << endl;
}
void findmax(int* a, int n, int& pk)
{
pk = 0;
for (int i = 1; i < n; i++)
{
if (a[i] > a[pk])
pk = i;
}
}
大学生请自行解决编程作业!