#include
#include
#include
#include
#include
char * s_gets(char * st, int n);
struct book { /* 简历 book 模板 /
char xulie[50];
int shudui[200];
};
using namespace std;
int main(void)
{
struct book X[100]; / book 类型结构的数组 */
if ('a' < 'c')
cout << "yes" << endl;
int n, m;
cin >> n >> m;
int i = 0;
char str1[12] = { '\0' };
s_gets(str1, 10);
while (i {
int num = 0;
cout cout for (int j = 0; j cout for (int k = j; k if (X[i].xulie[j]>X[i].xulie[k])
num++;
}
}
i++;
cout << num << endl;
cout << "---------------" << endl;
}
cout << "+++++++++++++" << endl;
}
char* s_gets(char* st, int n)
{
char* ret_val;
char* find;
ret_val = fgets(st, n, stdin);
if (ret_val)
{
find = strchr(st, '\n'); // 查找换行符
if (find) // 如果地址不是 NULL,
*find = '\0';
// 在此处放置一个空字符
else
while (getchar() != '\n')
continue; // 处理输入行中剩余的字符
}
return ret_val;
}
求问各位大神,为何我这里不能直接使用X[i].shudui=num;来直接给X[i].shudui赋值呢??
数组名 是一个 常量呀,不能给常量 赋值呀
你可以输出X[i].shudui看看 那是一个地址
并不是你想的数组成员
X[i].shudui[i] = num;
我知道不对在哪里了……我在定义struct的时候,不应该是int shudui【】,这样就把shudui定义成数组了。应该把【】去掉
不知道你这个问题是否已经解决, 如果还没有解决的话: