函数里的数组
请问下面这个简单的程序,错在哪里?
输入N个学生的四门功课的成绩,然后打印出来。
输入N个学生的四门功课的成绩,然后打印出来。
//随意输入N个学生的成绩,每个学生有四门课程
//如果输入0,0,0,0则表示输入结束
void read(int score[][4],int n){
//int score[][4];
int number = 0;
for(;;){
if(number > 0){
if(score[number-1][0] == 0 || number >= n)
break;
}
scanf("%f,%f,%f,%f",&score[number][0],&score[number][1],&score[number][2],&score[number][3]);
number++;
}
printf("you've input %d student's scores!\n",number);
int i = 0;
for(i = 0; i < number; i++)
{
printf("row[%d]:%f,%f,%f,%f\n",i+1,score[i][0],score[i][1],score[i][2],score[i][3]);
}
}
main(){
int num = 0;
int s[1000][4];
printf("input the total students you need to input:");
scanf("%d",&num);
printf("input scores:\n");
read(s,num);
}
...全文
相关推荐
数组做函数的形参,执行过程数组里的值变了
数组做函数的形参,执行过程数组里的值变了 C/C++
JavaScript通过join函数连接数组里所有元素的方法
本文实例讲述了JavaScript通过join函数连接数组里所有元素的方法。分享给大家供大家参考。具体实现方法如下:[removed]var days = ["Sunday","Monday","Tu
php使用gettimeofday函数返回当前时间并存放在关联数组里
在PHP编程语言中,`gettimeofday()` 是一个非常实用的内置函数,用于获取当前系统时间。这个函数可以返回一个关联数组,包含详细的时间信息。
查询一个指定字符在数组里的索引,返回索引
在编程领域,数组是一种基本的数据结构,用于存储同类型的元素集合。当我们需要在数组中查找特定的字符并获取其位置时,我们通常会涉及到“查询一个指定字符在数组里的索引”的操作。
03-python-choose 函数实现条件筛选-数组广播机制-数组读写-结构化数组
在Python的世界里,NumPy库是处理数值计算和科学计算的核心工具。本篇将深入探讨四个重要的知识点:`choose`函数实现条件筛选、数组广播机制、数组读写以及结构化数组。


