谁能解决这问题?
我是初学者,才一个月的,现在有两个作业题不会做的,各位好心人帮帮忙啊!1、输入50个数字,要求其值为0到4之间的整数,用-1作为结束标志符,并计算整数出现的个数;
2数组int a[2][3]={{1,2,3},{4,5,6},要求将a的行和列的元素互换后存到数组b中;
#include <stdio.h> #include <stdlib.h> #define MIN_NUM 0 #define MAX_NUM 4 void getInputCharCount(void) { int inputNum; int numIdx = 0; int countArray[MAX_NUM - MIN_NUM + 1] = {0}; do { printf("Input a number (0-4) and press enter key :"); scanf("%d", &inputNum); if (inputNum == -1) { break; } if (inputNum >= 0 && inputNum <= 4) { countArray[inputNum]++; } }while(1); // print for (numIdx = 0; numIdx <= MAX_NUM - MIN_NUM; numIdx++) { printf("%d appears %d Times\n", numIdx + MIN_NUM, countArray[numIdx]); } } void ReverseArray() { int array[2][3] = { {1, 2, 3}, {4, 5, 6} }; int array_new[3][2]; int i, j; for (i = 0; i < 3; i++) { for (j = 0; j < 2; j++) { array_new[i][j] = array[j][i]; printf("array_new[%d][%d] = %d\n", i, j, array_new[i][j]); } } } int main() { // call the functions above... system("pause"); return 0; }