. [Error] no match for ‘operator=‘ (operand types are ‘STU‘ and ‘int‘)

. [Error] no match for 'operator=' (operand types are 'STU' and 'int')

不能将结构体里的数组直接输入,而是通过遍历。

typedef struct{
    int no;
    float sc[3];
    float total;
    int rank;
}STU;


scanf("%6.d\t%3.1d\t3.1%d\t%3.1d\t%4.1d\t%d\n ",s[i].no,s[i].sc[1],s[i].sc[2],s[i].sc[0],s[i].total,s[i].rank);
这样是错的.
纠正:

for(int i=0;i<10;i++){
	scanf("%d ",&s[i].no);
	for(int j=0;j<3;j++)
	scanf("%f",&s[i].sc[j]);
}

你可能感兴趣的:(笔记,c++)