Advertisement
J00ker

asfd

Jan 6th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <fstream>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. /*
  11.  
  12. strstr
  13.  
  14. char text[200] = "X-G nu invata, nu munceste, nu persevereaza, nu ia note bune si nu adora biologia.";
  15. char *p;
  16.  
  17. while((p = strstr(text, "nu ")) != NULL)
  18. strcpy(p, p+3);
  19.  
  20. cout << text << "\n";
  21.  
  22. */
  23. //------------------------------------------------------------------------------------------------------
  24. /*
  25.  
  26. Avand un text format din cu separate prin caract .,;|? space,
  27. sa se memoreze fiecare cuvant intr-un vector de cuvinte.
  28.  
  29. */
  30.  
  31. /*
  32. char s[1001], *p, cuv[100][30];
  33. char sep[] = ",. ;?!:";
  34. int n; // n - numarul de cuvinte
  35.  
  36. ifstream fin("text.in");
  37. fin.getline(s, 999);
  38. fin.close();
  39.  
  40. n = 0;
  41. p = strtok(s, sep);
  42.  
  43. while(p != NULL)
  44. {
  45. strcpy(cuv[n], p);
  46. n++;
  47. p = strtok(NULL, sep);
  48. }
  49.  
  50. ofstream fout("text.out");
  51. for(int i = 0; i < n; i++)
  52. fout << cuv[i] << "\n";
  53. fout.close();
  54. */
  55.  
  56. //-------------"ALT PROIECT"------------------------------------------------------------------
  57.  
  58. char s[10001], *p;
  59. int a[1000], n;
  60. char sep[] = " ";
  61.  
  62. ifstream fin("numere.in");
  63. fin.getline(s, 9999);
  64. fin.close();
  65.  
  66. n = 0;
  67. p = strtok(s, sep);
  68.  
  69. while(p != NULL)
  70. {
  71. a[n] = atoi(p);
  72. n++;
  73. p = strtok(NULL, sep);
  74. }
  75.  
  76. for(int i = 0; i < n; i++)
  77. cout << a[i] << " ";
  78. cout << "\n";
  79.  
  80. return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement