【20年扬大真题】
编写程序,功能是从键盘输入若干4位数字学号,然后输出学号中百位数字是3的学号
(输入0时结束循环)
#include<stdio.h>
#define MaxSize 20
int BaiWei3(int x) {x = x / 100;if (x % 10 == 3) {return 1;}else {return 0;}
}
int main() {int i = 0;int arr[MaxSize] = { 0 };printf("请输入若干四位数字的学号,以0为结束标志:");for (i = 0;i <MaxSize;i++) {scanf("%d", &arr[i]);if (arr[i] == 0) {break;}}printf("百位数字为3的学号为:");for (i = 0;i < MaxSize;i++) {if (BaiWei3(arr[i])) {printf("%d ", arr[i]);}}return 0;
}