又来问问题了哈~编译时出错~求解~
先谢谢啦~输入10个学生的姓名、学号、成绩,然后输出其中不合格者。
代码如下
编译 连接时出错,如下:
--------------------Configuration: sy5_17 - Win32 Debug--------------------
Linking...
sy5_17.obj : error LNK2001: unresolved external symbol "int * fail" (?fail@@3PAHA)
sy5_17.obj : error LNK2001: unresolved external symbol "char * name" (?name@@3PADA)
sy5_17.obj : error LNK2001: unresolved external symbol "int * num" (?num@@3PAHA)
sy5_17.obj : error LNK2001: unresolved external symbol "int * grade" (?grade@@3PAHA)
Debug/sy5_17.exe : fatal error LNK1120: 4 unresolved externals
执行 link.exe 时出错.
sy5_17.exe - 1 error(s), 0 warning(s)
目前只学到数组,后面什么指针还有其他什么的还没学...
程序代码:
#include <iostream> using namespace std; void cheek(); char name[];int num[],grade[],fail[]; int k=0; int main() { int i; cout<<"请输入姓名、学号、成绩,中间以空格隔开:"<<endl; for(i=0;i<=9;i++) { cin>>name[i]>>num[i]>>grade[i]; cout<<endl; } cheek(); cout<<"不合格者为:"<<endl; for(i=0;i<=k;i++) cout<<name[fail[k]]<<num[fail[k]]<<grade[fail[k]]<<endl; return 0; } void cheek() { int i; for(i=0;i<=9;i++) { if(grade[i]<60) fail[k]=i;k++; //记录不及格者的数组下标 } }