主题:[讨论]请高手帮帮忙
写出下列每个函数的功能
1.bool WB(int a[ ] , int n , int x) {
for ( int i=0; i<n; i++ )
if (a[i] == x) return true ;
return false ;
}
2.template <class Type>
int WE(Type a[ ] , Type b[ ] , int n) {
int c = 0;
for ( int i=0; i<n; i++ )
if (a[i] == b[i]) c++;
return c;
}
3.void LK(int a[ ] , int n , int & m) {
float s = 0; int i;
for ( i=0; i<n; i++ ) s += a[i];
s /= n;
m = 0;
for ( i=0; i<n; i++ ) if (a[i] >= s) m++;
}
4.# include <iomanip.h>
# include <fstream.h>
# include <string.h>
void JA(char * fname)
// 可把以fname所指字符串作为文件标识符的文件称为fname文件
{
ofstream fout(fname);
char a[20]; cin >>a;
while (strcmp(a , “end”) != 0) {
fout <<a<<endl;
cin >>a;
}
fout.clase( );
}
1.bool WB(int a[ ] , int n , int x) {
for ( int i=0; i<n; i++ )
if (a[i] == x) return true ;
return false ;
}
2.template <class Type>
int WE(Type a[ ] , Type b[ ] , int n) {
int c = 0;
for ( int i=0; i<n; i++ )
if (a[i] == b[i]) c++;
return c;
}
3.void LK(int a[ ] , int n , int & m) {
float s = 0; int i;
for ( i=0; i<n; i++ ) s += a[i];
s /= n;
m = 0;
for ( i=0; i<n; i++ ) if (a[i] >= s) m++;
}
4.# include <iomanip.h>
# include <fstream.h>
# include <string.h>
void JA(char * fname)
// 可把以fname所指字符串作为文件标识符的文件称为fname文件
{
ofstream fout(fname);
char a[20]; cin >>a;
while (strcmp(a , “end”) != 0) {
fout <<a<<endl;
cin >>a;
}
fout.clase( );
}