本文介绍了我需要消除它的错误.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经为查找max和排序而编写了此c ++程序....它有一个错误,我找不到它为什么不能编译的错误...请在其编译中转发我....
i have written this c++ program for find max , and sorting .... it has one error which i can''t find why it doesn''t compile ... please forward me in its compiling ....
#include <iostream>
using namespace std;
#include <string.h>
#include <stdio.h>
// #include <conio.h>
#include <stdlib.h>
#include <cstring.h>
void swapname( char nam1[] , char nam2[])
{
char tempname[50]
strcpy (tempname , nam1);
strcpy (nam1 , nam2);
strcpy (nam2 , tempname);
}
void swapnumbers(float *num1 , float *num2)
{
float tempnum;
tempnum = *num1;
*num1 = *num2;
*num2 = tempnum;
}
int main ()
{
char nam[5][50];
int id [5];
float grade[5];
int level[5] , i , j , location , rotbeh;
float max;
system ("cls");
for(i=0 ; i<5 ; i++)
{
cout << " Enter a name " << i << " and a family : \n " ;
cin.getline(nam[i],50);
cout << " Enter An ID : \n " ;
cin >> id[i];
cout << "Enter a grade :" ;
cin >> grade[i];
}
for (i=0 ; i<4 ; i++)
{
max = garde [i] ; location = i;
for( j=i+1 ; j<5 ; j++)
if (grade[j] > max)
{
max = grade[j] ; location = j ;
}
swapname ( nam[i], nam[location]);
swapnumbers(&grade[i] , &grade[location]);
}
rotbeh = 1 ; level[0] = rotbeh ;
for (i=1 ; i<5 ; i++)
{
if(grade[i] != grade[i-1])
rotbeh = i;
level[i] = rotbeh ;
}
for ( i=0 ; i<5 ; i++)
{
cout << nam[i] ;
cout << grade[i] ;
cout << level[i];
}
return 0;
}
推荐答案
void swapname( char nam1[] , char nam2[])
{
char tempname[50]
成为
void swapname( char nam1[] , char nam2[])
{
char tempname[50];
这篇关于我需要消除它的错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!