Results 1 to 10 of 10
Thread: C++
Hybrid View
-
24th September 2012 21:32 #1
C++
. , .
4586 :
4586/1000=4
4586/100=458(6)
458/10=45(8)
45:/10=4(5)
, . :
c , x/100/10%10 x/100%10/10%10, d - x/100/100/10%10 x/100%10/100%10, s 15, 14, 9, 23 ( ), p 0. ? .Code:#include <iostream.h> int main() { int x,a,b,c,d,p,s; cout<<"x="; cin>>x; a=x/1000; b=x/100%10; c= d= s=a+b+c+d; p=a*b*c*d; cout<<"sum="<<s; cout<<"pro="<<p; system("pause"); return 0; }ASRock B450M Pro4 / 5700X@4.5GHz / MSI RX 6600 XT Mech 2X / be quiet! Dark Rock 4 / 2x16GB FlareX 3200MHz CL16 / FSP Hydro G Pro 1000W / Samsung Odyssey G5 S27AG50
-
24th September 2012 21:56 #2
, .
Like the coldest winter chill
Heaven beside you
Hell within
-
24th September 2012 22:09 #3
-
24th September 2012 22:20 #4??Code:
int x = 0; cin>>x; int a=0,b=0,c=0,d=0; d = x%10; c = (x/10)%10; b = (x/100)%10; a = (x/1000)%10; cout<<"a = "<<a<<" b = "<<b<<" c = "<<c<<" d = "<<d<<endl; cout<<"a+b+c+d = "<<a+b+c+d<<endl<<"a*b*c*d = "<<a*b*c*d<<endl;
: ++,
Last edited by tengam; 24th September 2012 at 22:52.
|ASUS RoG Z690-E i7-13700k@ 5.6/4.3Ghz + Kraken X63 216GB Kingston Fury Beast 6000hmz 32-40-40-28 | RTX4080 | 256GB 960Evo, 1TB 970Evo, 2x2TB 980Pro, 1TB 860Evo|HX1200|CM MasterCase Pro 5|
|Steam Deck 256GB | 36 TB Unraid NAS| Asus Z87-DELUXE i7-4790K 32GB DDR3|
TengaM#2700 / 7engaM
-
24th September 2012 22:13 #5
% (4586%10=6 ), /10 (4586/10=458) 458%10=8 .. , .
Gigabyte B150M-D3H; Intel Core i5-6500@3.2GHz;KINGSTON 2x4GB DDR4 2133MHz HyperX FURY;DEEPCOOL DA500-M Modular; GIGABYTE GeForce GTX 970 4GB G1 GAMING OC EDITION;Gigabyte g1 Gaming R9 380 4GB- RIP
-
24th September 2012 22:21 #6
-
24th September 2012 22:32 #7
, .
Gigabyte B150M-D3H; Intel Core i5-6500@3.2GHz;KINGSTON 2x4GB DDR4 2133MHz HyperX FURY;DEEPCOOL DA500-M Modular; GIGABYTE GeForce GTX 970 4GB G1 GAMING OC EDITION;Gigabyte g1 Gaming R9 380 4GB- RIP
-
24th September 2012 22:38 #8Mire-x
Join Date: Apr:2005
Location: Sofia
Posts: 763
, "cheat" , char[], ( 48, ASCII ):
EDIT: , ( , ... C++Code:char c[5]; int i, n, s = 0, m = 1; for (i = 0; i < 4; i++) { n = (int)c[i] - 48; s += n; m *= n; }
), , .
(10b) || !(10b)
-
24th September 2012 22:55 #9
( ):
, ...Code:#include <stdio.h> #include <math.h> #define BASE 10 int main() { int big; scanf("%d", &big); int digits; digits = 0; if (big == 0) { digits = 1; } else if(big != 0) { int count; count = big; while(count != 0) { count /= 10; digits++; } } int a[100]; int i; for(i = 0; i < digits; i++) { a[i] = (int) (big / pow(BASE, digits - 1 - i)) % BASE; } for(i = 0; i < digits; i++) { printf("%d\n", a[i]); } return 0; }
: "-lm" ( 'pow()').Like the coldest winter chill
Heaven beside you
Hell within
-
25th September 2012 22:51 #10Registered User
Join Date: Aug:2008
Location: Varna
Posts: 291
, :
.Code:#include <xmmintrin.h> #include <cstdio> int main( int argc, char **__argv ) { unsigned value = __argv[1][0] * 1000 + __argv[1][1] * 100 + __argv[1][2] * 10 + __argv[1][3] - '0' * 1111 ; printf( "input = %u\n", value++ ); __m64 r = _mm_mulhi_pu16 ( _mm_set1_pi16( value ), _mm_set_pi16( 0x10000 / 1000, 0x10000 / 100, 0x10000 / 10, 0xFFFF ) ); unsigned pck = _mm_cvtsi64_si32( _mm_packs_pu16( _mm_sub_pi16 ( r, _mm_mullo_pi16 ( _mm_mulhi_pu16 ( r, _mm_set1_pi16( 0x10000 / 10 ) ), _mm_set1_pi16( 10 ) ) ), _mm_setzero_si64() ) ); unsigned s = ( pck >> 16 ) + (unsigned short)pck, m = (unsigned char)pck; s = ( s >> 8 ) + (unsigned char)s; m *= (unsigned char)( pck >> 8 ); m *= (unsigned char)( pck >> 16 ); m *= (unsigned char)( pck >> 24 ); printf( "s = %u, m = %u\n", s, m ); return 0; }




Reply With Quote
...
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in