Advertisement
J00ker

Untitled

Jan 19th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8. void Citire(char* s)
  9. {
  10.     fstream fin("cale.txt");
  11.     fin.getline(s, 999);
  12.     fin.close();
  13. }
  14.  
  15. int NrFold(char* s)
  16. {
  17.     char *p;
  18.     int nr = 0;
  19.     p = strtok(s, "\\");
  20.     while((p = strtok(NULL, "\\")) != NULL)
  21.         nr++;
  22.     return nr-1;
  23. }
  24.  
  25. int main()
  26. {
  27.     char sir[999];
  28.     Citire(sir);
  29.     //cout << sir << "\n";
  30.     cout << NrFold(sir) << "\n";
  31.  
  32.     //-----3-----
  33.     int s = 0;
  34.     char *p, sep[] = "x=+ ", expr[99];
  35.     cin.getline(expr, 99); //scrii x=15+127
  36.     p = strtok(expr, sep);
  37.     while(p != NULL)
  38.     {
  39.         s += atoi(p);
  40.         p = strtok(NULL, sep);
  41.     }
  42.     cout << "x = " << s;
  43.  
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement