int x=1; int y=9;//除数 |
|
4分 |
1.换最新的VS
2.用C++ 3.用std::div( lldiv_t std::div(long long, long long) ) |
3分 |
vc没有long long,vc的64位整型是用__int64。
|
3分 |
long long 就是__int64
|
3分 |
int main(void) { long x = 1; long y = 9;//除数 int sh = 0; int yu = 0; lldiv_t temp; temp = lldiv(x, y); sh = temp.quot; //商 yu = temp.rem; ///余*/ cout << sh << endl; cout << yu << endl; return 0; } |
4分 |
C++ Language Reference
Data Type Ranges See Also Collapse All Expand All Language Filter: All Language Filter: Multiple Language Filter: Visual Basic Language Filter: C# Language Filter: C++ Language Filter: J# Language Filter: JScript Visual Basic (Declaration) Visual Basic (Usage) C# C++ J# JScript For 32-bit and 64-bit compilers, Microsoft Visual C++ recognizes the types shown in the table below. Note that the following type also have unsigned forms: int (unsigned int) __int8 (unsigned __int8) __int16 (unsigned __in16) __int32 (unsigned __in32) __int64 (unsigned __in64) char (unsigned char) short (unsigned short) long (unsigned long) long long (unsigned long long) Type Name Bytes Other Names Range of Values A variable of __wchar_t designates a wide-character or multibyte character type. By default wchar_t is a typedef for unsigned short. Use the L prefix before a character or string constant to designate the wide-character-type constant. When compiling with /Zc:wchar_t or /Za, the compiler can distinguish between an unsigned short and wchar_t for function overload purposes. Signed and unsigned are modifiers that can be used with any integral type except bool. The char type is signed by default, but you can specify /J (compiler option) to make it unsigned by default. The int and unsigned int types have the size of the system word: four bytes. However, portable code should not depend on the size of int. Microsoft C/C++ also features support for sized integer types. See __int8, __int16, __int32, __int64 for more information. Also see Integer Limits. See Fundamental Types for more information on the restrictions of the sizes of each type. See Also To make a suggestion or report a bug about Help or another feature of this product, go to the feedback site. |
4分 |
C++ Language Reference
C++ Integer Constants See Also Collapse All Expand All Language Filter: All Language Filter: Multiple Language Filter: Visual Basic Language Filter: C# Language Filter: C++ Language Filter: J# Language Filter: JScript Visual Basic (Declaration) Visual Basic (Usage) C# C++ J# JScript Integer constants are constant data elements that have no fractional parts or exponents. They always begin with a digit. You can specify integer constants in decimal, octal, or hexadecimal form. They can specify signed or unsigned types and long or short types. Grammar octal-constant integer-suffixopt hexadecimal-constant integer-suffixopt “”c-char-sequence”” decimal-constant: decimal-constant digit octal-constant: octal-constant octal-digit hexadecimal-constant: 0X hexadecimal-digit hexadecimal-constant hexadecimal-digit nonzero-digit: one of octal-digit: one of hexadecimal-digit: one of a b c d e f A B C D E F integer-suffix: long-suffix unsigned-suffixopt unsigned-suffix: one of long-suffix: one of 64-bit integer-suffix: To specify integer constants using octal or hexadecimal notation, use a prefix that denotes the base. To specify an integer constant of a given integral type, use a suffix that denotes the type. To specify a decimal constant, begin the specification with a nonzero digit. For example: Copy Code To specify an octal constant, begin the specification with 0, followed by a sequence of digits in the range 0 through 7. The digits 8 and 9 are errors in specifying an octal constant. For example: Copy Code To specify a hexadecimal constant, begin the specification with 0x or 0X (the case of the “x” does not matter), followed by a sequence of digits in the range 0 through 9 and a (or A) through f (or F). Hexadecimal digits a (or A) through f (or F) represent values in the range 10 through 15. For example: Copy Code To specify an unsigned type, use either the u or U suffix. To specify a long type, use either the l or L suffix. For example: Copy Code To specify a 64-bit integral type, use the LL, ll or i64 suffix. For example, Copy Code MyEnum f1(int) { MyEnum f1(__int64) { int main() { Output See Also To make a suggestion or report a bug about Help or another feature of this product, go to the feedback site. |
用vs的long long来求商和余数怎么做
|
|
4分 |
long long a,b,c; a=1000000001234ll; b=1000ll; c=a%b; printf("%lld\n",c);//234 |
5分 |
long long a,b,c,d; a=1000000001234ll; b=1000ll; c=a/b; d=a%b; printf("%lld,%lld\n",c,d); |
5分 |
乍看起来c++的cin、cout在输入、输出上比c的scanf、printf简单,不用格式控制符!
但是不用格式控制符,输入输出恰好是你期望的格式的时候好说;等到输入输出不是你期望的格式的时候,你就会觉得还是用格式控制符更方便、更靠谱。 摒弃cin、cout! 使用scanf、printf。 |
5分 |
用lldiv处理long long
|