elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


  Mostrar Mensajes
Páginas: [1] 2 3
1  Programación / Programación C/C++ / Re: Hola, quiero modificar los tags de un archivo mp3, ayuda porfavor en: 19 Mayo 2017, 00:05 am
Gracias, ya he visto todas las páginas anteriores y más, el todo es que no sé modificar aún eso.
2  Programación / Programación C/C++ / Re: Hola, quiero modificar los tags de un archivo mp3, ayuda porfavor en: 17 Mayo 2017, 21:01 pm
Cómo instalo la biblioteca #include <id3/tag.h> ??? Nunca he hecho algo parecido...
3  Programación / Programación C/C++ / Re: Hola, quiero modificar los tags de un archivo mp3, ayuda porfavor en: 17 Mayo 2017, 20:36 pm
Quizás no es lo que buscas, pero dispones de una lib para modificar los tags.

Lo bueno es que es open source y puedes mirar cómo ha resuelto el tema el programador: https://sourceforge.net/projects/id3lib/files/id3lib/

Source: http://stackoverflow.com/questions/19928569/id3v2-tag-for-mp3-using-c

Espero te sea de utilidad.

Saludos!
Ammm... No entiendo, cómo se usa?
4  Programación / Programación C/C++ / Hola, quiero modificar los tags de un archivo mp3, ayuda porfavor en: 17 Mayo 2017, 19:58 pm
Este es el código que uso para leer el archivo mp3, pueden probarlo y les muestra los tag,s título, album, los priv, todo, esta para la versión de ID3v2.3.0, espero puedan ayudarme, lo que se quiere es que se le va a mostrar al usuario algo así, ejemplo:
Nombre de la canción: cancionblablabla
Álbum: blablba
Año: 1997
entonces esos datos entran como tag a la canción, gracias.
Código
  1. #include <iostream>
  2. #include <cstring>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6. //-------------------------------------------------------------------------
  7. typedef unsigned char byte;
  8. typedef unsigned int uint;
  9. typedef struct synch {
  10.    byte b3,b2,b1,b0;
  11. } sint;
  12. //-------------------------------------------------------------------------
  13. struct header
  14. {
  15.    char mark[3];
  16.    byte version[2];
  17.    byte flags;
  18.    sint size;
  19. };
  20. //-------------------------------------------------------------------------
  21. struct frame
  22. {
  23.    char id[4];
  24.    sint size;
  25.    byte flags[2];
  26. };
  27. //-------------------------------------------------------------------------
  28. uint usych(sint value)
  29. {
  30.    return value.b0|value.b1<<8|value.b2<<16|value.b3<<24;
  31. }
  32. //-------------------------------------------------------------------------
  33. int main()
  34. {
  35.    FILE *file=fopen("D:/Programacion/P1/ID3/cancion.mp3","r");
  36.    if(!file)
  37.    {
  38.        cout<<"File not found"<<endl;
  39.        return 0;
  40.    }
  41.    header hd;
  42.    fread(&hd,10,1,file);
  43.    if(strncmp(hd.mark,"ID3",3)!=0)
  44.    {
  45.        cout << "This file hasn't TAG" << endl;
  46.        fclose(file);
  47.        return 0;
  48.    }
  49.    cout << "Version :         "<< (int)hd.version[0]<<"."<<(int)hd.version[1] << endl;
  50.    cout << "Flags :           "<< (int)hd.flags << endl;
  51.    cout << "size :            " << usych(hd.size)<< endl;
  52.  
  53.    if(hd.version[0] < 3)
  54.    {
  55.        cout<<"Version doesn't match"<< endl;
  56.        fclose(file);
  57.        return 0;
  58.    }
  59.    char buffer;
  60.    while(true)
  61.    {
  62.        frame fr;
  63.        fread(&fr,10,1,file);
  64.        if(fr.id[0]<'A')break;
  65.        cout << endl << fr.id[0] << fr.id[1] << fr.id[2] << fr.id[3];
  66.        cout <<"   "<< usych(fr.size)<<" bytes... ";
  67.        if(fr.id[0]!='T'){
  68.            fseek(file,usych(fr.size),SEEK_CUR);
  69.            cout << "(Empty)" << endl;
  70.        }else{
  71.            cout << "(";
  72.            for(uint i=0;i<usych(fr.size);i++)
  73.            {
  74.                fread(&buffer,1,1,file);
  75.                if(buffer >= 32 && buffer <=126){
  76.                    cout << buffer;
  77.                }
  78.            }
  79.            cout << ")" << endl;
  80.        }
  81.    }
  82.    cout << endl;
  83.  
  84.    fclose(file);
  85.  
  86.    return 0;
  87. }
  88.  
5  Programación / Programación C/C++ / Ayuda con validación porfavor en: 31 Octubre 2016, 05:26 am
Hola a todos, sucede que tengo problema con esta validación, el usuario no puede escribir ningun cosa diferente a los números de 0 a 9, sin embargo cuando ingreso por ejemplo 5asdf, si lo permite y necesito validar eso, he intentado mucho y no he podido, espero su ayuda gracias
Código
  1. #include <iostream>
  2. #include <locale.h>
  3. #include <string>
  4. using namespace std;
  5.  
  6.  
  7. //----------------------------------------------------------------------------------------------------------
  8. string val(string n)
  9. {
  10. string c, p;
  11. int i;
  12. //
  13. for (i = 0; i <= 10; i++)
  14. {
  15. c = n.at(i);
  16. if (c != "0" && c != "1" && c != "2" && c != "3" && c != "4" && c != "5" && c != "6" && c != "7" && c != "8" && c != "9")
  17. {
  18. p = "0";
  19. }
  20. break;
  21. }
  22. return p;
  23.  
  24. }
  25. //----------------------------------------------------------------------------------------------------------
  26. void Units(string n)
  27. {
  28. if (n == "0") cout << "zero"; else
  29. if (n == "1") cout << "one"; else
  30. if (n == "2") cout << "two"; else
  31. if (n == "3") cout << "three"; else
  32. if (n == "4") cout << "four"; else
  33. if (n == "5") cout << "five"; else
  34. if (n == "6") cout << "six"; else
  35. if (n == "7") cout << "seven"; else
  36. if (n == "8") cout << "eight"; else
  37. if (n == "9") cout << "nine";
  38. }
  39.  
  40. //----------------------------------------------------------------------------------------------------------
  41.  
  42. //--------------------------------------------------------------------------------------------------------------------------------------------------
  43. void Tens(string n)
  44. {
  45. char t = n.at(0);
  46. char u = n.at(1);
  47. n = n.substr(1, 1);
  48. //
  49. if (t == '0' && u != '0')
  50. {
  51. Units(n);
  52. }
  53. if (t == '1')
  54. {
  55. if (u == '0') cout << "ten"; else
  56. if (u == '1') cout << "eleven"; else
  57. if (u == '2') cout << "twelve"; else
  58. if (u == '3') cout << "thirteen"; else
  59. if (u == '4') cout << "fourteen"; else
  60. if (u == '5') cout << "fifteen";
  61. else
  62. {
  63. Units(n);
  64. cout << "teen";
  65.  
  66. }
  67.  
  68. }
  69. if (t == '2')
  70. {
  71. if (u == '0') cout << "twenty";
  72. else
  73. {
  74. cout << "twenty- ";
  75. Units(n);
  76. }
  77. }
  78. if (t == '3')
  79. {
  80. if (u == '0') cout << "thirty";
  81. else
  82. {
  83. cout << "thirty-";
  84. Units(n);
  85. }
  86. }
  87. if (t == '4')
  88. {
  89. if (6u == '0') cout << "forty";
  90. else
  91. {
  92. cout << "forty- ";
  93. Units(n);
  94. }
  95. }
  96. if (t == '5')
  97. {
  98. if (u == '0') cout << "fifty";
  99. else
  100. {
  101. cout << "fifty-";
  102. Units(n);
  103. }
  104. }
  105. if (t == '6')
  106. {
  107. if (u == '0') cout << "sixty";
  108. else
  109. {
  110. cout << "sixty-";
  111. Units(n);
  112. }
  113. }
  114. if (t == '7')
  115. {
  116. if (u == '0') cout << "seventy";
  117. else
  118. {
  119. cout << "seventy-";
  120. Units(n);
  121. }
  122. }
  123. if (t == '8')
  124. {
  125. if (u == '0') cout << "eighty";
  126. else
  127. {
  128. cout << "eighty-";
  129. Units(n);
  130. }
  131. }
  132. if (t == '9')
  133. {
  134. if (u == '0') cout << "ninety";
  135. else
  136. {
  137. cout << "ninety-";
  138. Units(n);
  139. }
  140. }
  141.  
  142. }
  143.  
  144. //--------------------------------------------------------------------------------------------------------------------------------------------------
  145. //--------------------------------------------------------------------------------------------------------------------------------------------------
  146. void Hundreds(string n)
  147. {
  148. char t = n.at(0);
  149. char u = n.at(1);
  150. char v = n.at(2);
  151. n = n.substr(1, 2);
  152.  
  153. if (t == '0')
  154. {
  155. Tens(n);
  156. }
  157. if (t == '1')
  158. {
  159.  
  160. if (u == '0'&& v == '0') cout << "One hundred";
  161. else
  162. {
  163. cout << "One hundred and ";
  164. Tens(n);
  165. }
  166. }
  167. if (t == '2')
  168. {
  169. if (u == '0'&& v == '0') cout << "Two hundred";
  170. else
  171. {
  172. cout << "Two hundred and ";
  173. Tens(n);
  174. }
  175. }
  176. if (t == '3')
  177. {
  178. if (u == '0'&& v == '0') cout << "Three hundred";
  179. else
  180. {
  181. cout << "Three hundred and ";
  182. Tens(n);
  183. }
  184. }
  185. if (t == '4')
  186. {
  187. if (u == '0'&& v == '0') cout << "Four hundred";
  188. else
  189. {
  190. cout << "Four hundred and ";
  191. Tens(n);
  192. }
  193. }
  194. if (t == '5')
  195. {
  196. if (u == '0'&& v == '0') cout << "Five hundred";
  197. else
  198. {
  199. cout << "Five hundred and ";
  200. Tens(n);
  201. }
  202. }
  203. if (t == '6')
  204. {
  205. if (u == '0'&& v == '0') cout << "Six hundred";
  206. else
  207. {
  208. cout << "Six hundred and ";
  209. Tens(n);
  210. }
  211. }
  212. if (t == '7')
  213. {
  214. if (u == '0'&& v == '0') cout << "Seven hundred";
  215. else
  216. {
  217. cout << "Seven hundred and ";
  218. Tens(n);
  219. }
  220. }
  221. if (t == '8')
  222. {
  223. if (u == '0'&& v == '0') cout << "Eight hundred";
  224. else
  225. {
  226. cout << "Eight hundred and ";
  227. Tens(n);
  228. }
  229. }
  230. if (t == '9')
  231. {
  232. if (u == '0'&& v == '0') cout << "Nine hundred";
  233. else
  234. {
  235. cout << "Nine hundred and ";
  236. Tens(n);
  237. }
  238. }
  239. }
  240. //---------------------------------------------------------------------------------------------------------------------------------------------------
  241.  
  242. //---------------------------------------------------------------------------------------------------------------------------------------------------
  243. void Thousands(string n)
  244. {
  245. char t = n.at(0);
  246. char u = n.at(1);
  247. char v = n.at(2);
  248. char w = n.at(3);
  249. n = n.substr(1, 3);
  250.  
  251. if (t == '0')
  252. {
  253. Hundreds(n);
  254. }
  255. if (t == '1')
  256. {
  257. if (u == '0' && v == '0'&& w == '0') cout << "One thousand";
  258. else
  259. {
  260. cout << "One thousand ";
  261. Hundreds(n);
  262. }
  263. }
  264. if (t == '2')
  265. {
  266. if (u == '0' && v == '0'&& w == '0') cout << "Two thousand";
  267. else
  268. {
  269. cout << "Two thousand ";
  270. Hundreds(n);
  271. }
  272. }
  273. if (t == '3')
  274. {
  275. if (u == '0' && v == '0'&& w == '0') cout << "three thousand";
  276. else
  277. {
  278. cout << "three thousand ";
  279. Hundreds(n);
  280. }
  281. }
  282. if (t == '4')
  283. {
  284. if (u == '0' && v == '0'&& w == '0') cout << "four thousand";
  285. else
  286. {
  287. cout << "four thousand ";
  288. Hundreds(n);
  289. }
  290. }
  291. if (t == '5')
  292. {
  293. if (u == '0' && v == '0'&& w == '0') cout << "five thousand";
  294. else
  295. {
  296. cout << "five thousand ";
  297. Hundreds(n);
  298. }
  299. }
  300. if (t == '6')
  301. {
  302. if (u == '0' && v == '0'&& w == '0') cout << "six thousand";
  303. else
  304. {
  305. cout << "six thousand ";
  306. Hundreds(n);
  307. }
  308. }
  309. if (t == '7')
  310. {
  311. if (u == '0' && v == '0'&& w == '0') cout << "seven thousand";
  312. else
  313. {
  314. cout << "seven thousand ";
  315. Hundreds(n);
  316. }
  317. }
  318. if (t == '8')
  319. {
  320. if (u == '0' && v == '0'&& w == '0') cout << "eight thousand";
  321. else
  322. {
  323. cout << "eight thousand ";
  324. Hundreds(n);
  325. }
  326. }
  327. if (t == '9')
  328. {
  329. if (u == '0' && v == '0'&& w == '0') cout << "nine thousand";
  330. else
  331. {
  332. cout << "nine thousand ";
  333. Hundreds(n);
  334. }
  335. }
  336.  
  337.  
  338. }
  339. //--------------------------------------------------------------------------------------------------------------------------------------------------
  340.  
  341. //--------------------------------------------------------------------------------------------------------------------------------------------------
  342. void Thousands2(string n)
  343. {
  344. char t = n.at(0);
  345. char u = n.at(1);
  346. char v = n.at(2);
  347. char w = n.at(3);
  348. char x = n.at(4);
  349. n = n.substr(1, 4);
  350.  
  351. if (t == '0')
  352. {
  353. Thousands(n);
  354. }
  355. if (t == '1')
  356. {
  357. string temp = "";
  358. temp.resize(10);
  359. temp[0] = t;
  360. temp[1] = u;
  361. temp[2] = v;
  362. temp[3] = w;
  363. temp[4] = x;
  364. Tens(temp);
  365. cout << " thousand ";
  366. temp = &temp[2];
  367. Hundreds(temp);
  368. return;
  369. }
  370. if (t == '2')
  371. {
  372. if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "twenty thousand";
  373. else
  374. {
  375. cout << "twenty-";
  376. Thousands(n);
  377. }
  378. }
  379. if (t == '3')
  380. {
  381. if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "thirty thousand";
  382. else
  383. {
  384. cout << "thirty-";
  385. Thousands(n);
  386. }
  387. }
  388. if (t == '4')
  389. {
  390. if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "forty thousand";
  391. else
  392. {
  393. cout << "forty-";
  394. Thousands(n);
  395. }
  396. }
  397. if (t == '5')
  398. {
  399. if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "fifty thousand";
  400. else
  401. {
  402. cout << "fifty-";
  403. Thousands(n);
  404. }
  405. }
  406. if (t == '6')
  407. {
  408. if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "sixty thousand";
  409. else
  410. {
  411. cout << "sixty-";
  412. Thousands(n);
  413. }
  414. }
  415. if (t == '7')
  416. {
  417. if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "seventy thousand";
  418. else
  419. {
  420. cout << "seventy-";
  421. Thousands(n);
  422. }
  423. }
  424. if (t == '8')
  425. {
  426. if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "eighty thousand";
  427. else
  428. {
  429. cout << "eighty-";
  430. Thousands(n);
  431. }
  432. }
  433. if (t == '9')
  434. {
  435. if (u == '0' && v == '0'&& w == '0' && x == '0') cout << "ninety thousand";
  436. else
  437. {
  438. cout << "ninety-";
  439. Thousands(n);
  440. }
  441. }
  442.  
  443.  
  444. }
  445. //-----------------------------------------------------------------------------------------------------------------------
  446.  
  447. //--------------------------------------------------------------------------------------------------------------------------------------------------
  448. void Thousands3(string n)
  449. {
  450. char t = n.at(0);
  451. char u = n.at(1);
  452. char v = n.at(2);
  453. char w = n.at(3);
  454. char x = n.at(4);
  455. char y = n.at(5);
  456. n = n.substr(1, 5);
  457.  
  458. if (t == '0')
  459. {
  460. Thousands2(n);
  461. }
  462. if (t == '1')
  463. {
  464. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "one hundred thousand ";
  465. else
  466. {
  467. cout << "one hundred and ";
  468. Thousands2(n);
  469. }
  470. }
  471. if (t == '2')
  472. {
  473. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "two hundred thousand ";
  474. else
  475. {
  476. cout << "two hundred and ";
  477. Thousands2(n);
  478. }
  479. }
  480. if (t == '3')
  481. {
  482. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "three hundred thousand";
  483. else
  484. {
  485. cout << "three hundred and ";
  486. Thousands2(n);
  487. }
  488. }
  489. if (t == '4')
  490. {
  491. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "four hundred thousand";
  492. else
  493. {
  494. cout << "four hundred and ";
  495. Thousands2(n);
  496. }
  497. }
  498. if (t == '5')
  499. {
  500. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "five hundred thousand";
  501. else
  502. {
  503. cout << "five hundred and ";
  504. Thousands2(n);
  505. }
  506. }
  507. if (t == '6')
  508. {
  509. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "six hundred thousand";
  510. else
  511. {
  512. cout << "six hundred and ";
  513. Thousands2(n);
  514. }
  515. }
  516. if (t == '7')
  517. {
  518. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "seven hundred thousand";
  519. else
  520. {
  521. cout << "seven hundred and ";
  522. Thousands2(n);
  523. }
  524. }
  525. if (t == '8')
  526. {
  527. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "eight hundred thousand";
  528. else
  529. {
  530. cout << "eight hundred and ";
  531. Thousands2(n);
  532. }
  533. }
  534. if (t == '9')
  535. {
  536. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0') cout << "nine hundred thousand";
  537. else
  538. {
  539. cout << "nine hundred and ";
  540. Thousands2(n);
  541. }
  542. }
  543.  
  544.  
  545. }
  546. //-----------------------------------------------------------------------------------------------------------------------
  547. //--------------------------------------------------------------------------------------------------------------------------------------------------
  548. void Millions(string n)
  549. {
  550. char t = n.at(0);
  551. char u = n.at(1);
  552. char v = n.at(2);
  553. char w = n.at(3);
  554. char x = n.at(4);
  555. char y = n.at(5);
  556. char z = n.at(6);
  557. n = n.substr(1, 6);
  558.  
  559. if (t == '0')
  560. {
  561. Thousands3(n);
  562. }
  563. if (t == '1')
  564. {
  565. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "one million ";
  566. else
  567. {
  568. cout << "one million, ";
  569. Thousands3(n);
  570. }
  571. }
  572. if (t == '2')
  573. {
  574. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "two million ";
  575. else
  576. {
  577. cout << "two million, ";
  578. Thousands3(n);
  579. }
  580. }
  581. if (t == '3')
  582. {
  583. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "three million";
  584. else
  585. {
  586. cout << "three million, ";
  587. Thousands3(n);
  588. }
  589. }
  590. if (t == '4')
  591. {
  592. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "four million";
  593. else
  594. {
  595. cout << "four million, ";
  596. Thousands3(n);
  597. }
  598. }
  599. if (t == '5')
  600. {
  601. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "five million";
  602. else
  603. {
  604. cout << "five million, ";
  605. Thousands3(n);
  606. }
  607. }
  608. if (t == '6')
  609. {
  610. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "six million";
  611. else
  612. {
  613. cout << "six million, ";
  614. Thousands3(n);
  615. }
  616. }
  617. if (t == '7')
  618. {
  619. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "seven million";
  620. else
  621. {
  622. cout << "seven million, ";
  623. Thousands3(n);
  624. }
  625. }
  626. if (t == '8')
  627. {
  628. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "eight million";
  629. else
  630. {
  631. cout << "eight million, ";
  632. Thousands3(n);
  633. }
  634. }
  635. if (t == '9')
  636. {
  637. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0') cout << "nine million";
  638. else
  639. {
  640. cout << "nine million, ";
  641. Thousands3(n);
  642. }
  643. }
  644.  
  645.  
  646. }
  647. //-----------------------------------------------------------------------------------------------------------------------
  648. //--------------------------------------------------------------------------------------------------------------------------------------------------
  649. void Millions2(string n)
  650. {
  651. char t = n.at(0);
  652. char u = n.at(1);
  653. char v = n.at(2);
  654. char w = n.at(3);
  655. char x = n.at(4);
  656. char y = n.at(5);
  657. char z = n.at(6);
  658. char z2 = n.at(7);
  659. n = n.substr(1, 7);
  660.  
  661. if (t == '0')
  662. {
  663. Millions(n);
  664. }
  665. if (t == '1')
  666. {//11
  667. string temp = "";//112000
  668. temp.resize(10);
  669. temp[0] = t;
  670. temp[1] = u;
  671. temp[2] = v;
  672. temp[3] = w;
  673. temp[4] = x;
  674. temp[5] = y;
  675. temp[6] = z;
  676. temp[7] = z2;
  677. Tens(temp);
  678. cout << " million ";
  679. temp = &temp[2];//12000000
  680. Thousands3(temp);
  681. return;
  682. }
  683. if (t == '2')
  684. {
  685. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "twenty million ";
  686. else
  687. {
  688. cout << "twenty million ";
  689. Millions(n);
  690. }
  691. }
  692. if (t == '3')
  693. {
  694. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "thirty million";
  695. else
  696. {
  697. cout << "thirty million ";
  698. Millions(n);
  699. }
  700. }
  701. if (t == '4')
  702. {
  703. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "forty million";
  704. else
  705. {
  706. cout << "forty million ";
  707. Millions(n);
  708. }
  709. }
  710. if (t == '5')
  711. {
  712. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "fifty million";
  713. else
  714. {
  715. cout << "fifty million ";
  716. Millions(n);
  717. }
  718. }
  719. if (t == '6')
  720. {
  721. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "sixty million";
  722. else
  723. {
  724. cout << "sixty million ";
  725. Millions(n);
  726. }
  727. }
  728. if (t == '7')
  729. {
  730. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "seventy million";
  731. else
  732. {
  733. cout << "seventy million ";
  734. Millions(n);
  735. }
  736. }
  737. if (t == '8')
  738. {
  739. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "eighty million";
  740. else
  741. {
  742. cout << "eighty million ";
  743. Millions(n);
  744. }
  745. }
  746. if (t == '9')
  747. {
  748. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0') cout << "ninety million";
  749. else
  750. {
  751. cout << "ninety million ";
  752. Millions(n);
  753. }
  754. }
  755.  
  756.  
  757. }
  758. //-----------------------------------------------------------------------------------------------------------------------
  759. //--------------------------------------------------------------------------------------------------------------------------------------------------
  760. void Millions3(string n)
  761. {
  762. char t = n.at(0);
  763. char u = n.at(1);
  764. char v = n.at(2);
  765. char w = n.at(3);
  766. char x = n.at(4);
  767. char y = n.at(5);
  768. char z = n.at(6);
  769. char z2 = n.at(7);
  770. char z3 = n.at(8);
  771. n = n.substr(1, 8);
  772.  
  773. if (t == '0')
  774. {
  775. Millions2(n);
  776. }
  777. if (t == '1')
  778. {
  779. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "one hundred million ";
  780. else
  781. {
  782. cout << "one hundred and ";
  783. Millions2(n);
  784. }
  785. }
  786. if (t == '2')
  787. {
  788. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "two hundred million ";
  789. else
  790. {
  791. cout << "two hundred and ";
  792. Millions2(n);
  793. }
  794. }
  795. if (t == '3')
  796. {
  797. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "three hundred million";
  798. else
  799. {
  800. cout << "three hundred and ";
  801. Millions2(n);
  802. }
  803. }
  804. if (t == '4')
  805. {
  806. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "four hundred million";
  807. else
  808. {
  809. cout << "four hundred and ";
  810. Millions2(n);
  811. }
  812. }
  813. if (t == '5')
  814. {
  815. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "five hundred million";
  816. else
  817. {
  818. cout << "five hundred and ";
  819. Millions2(n);
  820. }
  821. }
  822. if (t == '6')
  823. {
  824. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "six hundred million";
  825. else
  826. {
  827. cout << "six hundred and ";
  828. Millions2(n);
  829. }
  830. }
  831. if (t == '7')
  832. {
  833. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "seven hundred million";
  834. else
  835. {
  836. cout << "seven hundred and ";
  837. Millions2(n);
  838. }
  839. }
  840. if (t == '8')
  841. {
  842. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "eight hundred million";
  843. else
  844. {
  845. cout << "eight hundred and ";
  846. Millions2(n);
  847. }
  848. }
  849. if (t == '9')
  850. {
  851. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0') cout << "nine hundred million";
  852. else
  853. {
  854. cout << "nine hundred and ";
  855. Millions2(n);
  856. }
  857. }
  858.  
  859.  
  860. }
  861. //-----------------------------------------------------------------------------------------------------------------------
  862.  
  863. //--------------------------------------------------------------------------------------------------------------------------------------------------
  864. void Millions4(string n)
  865. {
  866. char t = n.at(0);
  867. char u = n.at(1);
  868. char v = n.at(2);
  869. char w = n.at(3);
  870. char x = n.at(4);
  871. char y = n.at(5);
  872. char z = n.at(6);
  873. char z2 = n.at(7);
  874. char z3 = n.at(8);
  875. char z4 = n.at(8);
  876. n = n.substr(1, 9);
  877.  
  878. if (t == '0')
  879. {
  880. Millions3(n);
  881. }
  882. if (t == '1')
  883. {
  884. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "one billion ";
  885. else
  886. {
  887. cout << "one billion, ";
  888. Millions3(n);
  889. }
  890. }
  891. if (t == '2')
  892. {
  893. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "two billion ";
  894. else
  895. {
  896. cout << "two billion, ";
  897. Millions3(n);
  898. }
  899. }
  900. if (t == '3')
  901. {
  902. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "three billion";
  903. else
  904. {
  905. cout << "three billion, ";
  906. Millions3(n);
  907. }
  908. }
  909. if (t == '4')
  910. {
  911. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "four billion";
  912. else
  913. {
  914. cout << "four billion, ";
  915. Millions3(n);
  916. }
  917. }
  918. if (t == '5')
  919. {
  920. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "five billion";
  921. else
  922. {
  923. cout << "five billion, ";
  924. Millions3(n);
  925. }
  926. }
  927. if (t == '6')
  928. {
  929. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "six billion";
  930. else
  931. {
  932. cout << "six billion, ";
  933. Millions3(n);
  934. }
  935. }
  936. if (t == '7')
  937. {
  938. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "seven billion";
  939. else
  940. {
  941. cout << "seven billion, ";
  942. Millions3(n);
  943. }
  944. }
  945. if (t == '8')
  946. {
  947. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "eight billion";
  948. else
  949. {
  950. cout << "eight billion, ";
  951. Millions3(n);
  952. }
  953. }
  954. if (t == '9')
  955. {
  956. if (u == '0' && v == '0'&& w == '0' && x == '0' && y == '0' && z == '0' && z2 == '0' && z3 == '0' && z4 == '0') cout << "nine billion";
  957. else
  958. {
  959. cout << "nine billion, ";
  960. Millions3(n);
  961. }
  962. }
  963.  
  964.  
  965. }
  966. //-----------------------------------------------------------------------------------------------------------------------
  967.  
  968. int main()
  969. {
  970. int i, c;
  971. string num, n, r, g;
  972. //
  973. cout << "===============================\n";
  974. cout << "= Convert numbers to letters  =\n";
  975. cout << "===============================\n\n";
  976. do
  977. {
  978.  
  979. do
  980. {
  981. cout << "Type a number up to 10 digits to convert in Written English: "; getline(cin, n);
  982. c = n.size();
  983. if (c == NULL) g = "0";
  984. else g = val(n);
  985. } while (c > 10 || g == "0");
  986.  
  987. switch (n.length())
  988. {
  989. case 1: Units(n); break;
  990. case 2: Tens(n); break;
  991. case 3: Hundreds(n); break;
  992. case 4: Thousands(n); break;
  993. case 5: Thousands2(n); break;
  994. case 6: Thousands3(n); break;
  995. case 7: Millions(n); break;
  996. case 8: Millions2(n); break;
  997. case 9: Millions3(n); break;
  998. case 10: Millions4(n); break;
  999. }
  1000.  
  1001. cout << endl;
  1002. cout << "Another number?:(Y/N) "; getline(cin, r);
  1003. } while (r == "y" || r == "Y");
  1004.  
  1005. cout << "\n\nHOMEWORK # 2\nAuthor: Giancarlo Rosero Portillo\nto: Jesus Insuasti\n";
  1006. system("pause");
  1007. return 0;
  1008. }
6  Programación / PHP / Re: Explicación quicksort usando recursividad en: 7 Junio 2016, 03:36 am
Lo estoy haciendo en diagrama de flujo
sin embargo tengo esto de código:
START
    menor=1
    REPEAT
        WRITE "Cuantos números ingresará: ?"
        READ n
        IF n<2 THEN
            WRITE "Ingrese un número mayor o igual a 2"
        ENDIF
    TO n>=2
    FOR i = 1 TO n STEP 1 DO
        WRITE "Ingrese valor para la posición",i,"del vector: "
        READ valor
        vector=valor
    ENDFOR
    nuevo=CALL ordenamiento(vector,1,n)
END
ENTER vector,inicio,final
    izq=inicio
    der=final
    pivote=vector[(inicio+final)]//2
    WHILE izq<=der DO
        FOR izq = inicio TO vector[izq]-1 STEP 1 DO
            FOR der = final TO vector[der] STEP -1 DO
                IF izq<=der THEN
                    temp=vector[izq]
                    vector[izq]=vector[der]
                    vector[der]=temp
                    izq=izq+1
                    der=der-1
                ENDIF
            ENDFOR
        ENDFOR
    ENDWHILE
    IF inicio<der THEN
        ordenamiento(vector,inicio,der)
    ENDIF
    IF izq<final THEN
        ordenamiento(vector,izq,final)
    ENDIF
RETURN
7  Programación / PHP / Explicación quicksort usando recursividad en: 7 Junio 2016, 03:21 am
Hola, vengo a pedir ayudaaaa :-( :-( alguien podría explicarme como funciona el método de ordenamiento quicksort usando la recursividad? He estado mucho tiempo intentando realizarlo pero no me sale, solo me da algún error y así, debo ingresar n números a un vector, luego ordenarlos por ese método, he visto vídeos y no me funcionan las cosas, quería ponerlo en diagrama de flujo para ver si entendía mejor pero nada, espero me ayuden pronto, tengo desesperación T.T :-( gracias...
8  Foros Generales / Dudas Generales / Re: Valor absoluto en: 28 Febrero 2016, 21:22 pm
Eso continúa sin solucionar mi problema :/
9  Foros Generales / Dudas Generales / Re: Valor absoluto en: 28 Febrero 2016, 01:13 am
De ese tipo los entiendo, si te fijas el mío es algo diferente, involucra doble valor absoluto...  :-[
10  Foros Generales / Dudas Generales / Valor absoluto en: 27 Febrero 2016, 23:55 pm
Hola, pueden ayudarme con algo que no entiendo... Es de valor absoluto:
Este es el punto:

|2x-1|x+1||=x-2

Tengo un buen poco de esos ejercicios pero con uno que sepa como se hace ya puedo hacer los otros, espero me ayuden, muchas gracias!
Páginas: [1] 2 3
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines