类与对象的异常 Cpp异常 #include <iostream> #include <string.h> using namespace std; //标识错误的类型 class wrong { }; int intdiv(int a, int b) { try { if (b==0) { throw 10;//能够是不论什么对象 wrong(); } int c = a / b; return c; } catch (int data )//类型名 { cout <<
1 Two Sum Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2,