有以下两个代码: package com.lk.A; public class Test3 { public static void main(String[] args) { try { int a = args.length; int b = 42/a; int c[] = {42}; c[42] = 42; System.out.println("b="+b); } catch (ArithmeticException e) { // TODO: handle exception…
关于C++的scanf,其实在使用时有一个注意的点. 我们来看一个简单的例子. 对于输入的一行,如果这一行的开头需要输入一个字符,例如这样的输入: A 10 20 B 30 A 3 50 ... 我们可以使用这种方式来读入,使用一段代码来进行试验: #include<stdio.h> using namespace std; int main(){ int n; scanf("%d",&n); while(n--){ char c; scanf("%c&q…
题目:找出一个数组中第m小的值并输出. 代码: #include <stdio.h> int findm_min(int a[], int n, int m) //n代表数组长度,m代表找出第m小的数据 { int left, right, privot, temp; int i, j; left = 0; right = n - 1; while(left < right) { privot = a[m-1]; i = left; j = right; do { while(privo…