Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cstring>
- #include <cstdlib>
- using namespace std;
- void Citire(char* s)
- {
- fstream fin("cale.txt");
- fin.getline(s, 999);
- fin.close();
- }
- int NrFold(char* s)
- {
- char *p;
- int nr = 0;
- p = strtok(s, "\\");
- while((p = strtok(NULL, "\\")) != NULL)
- nr++;
- return nr-1;
- }
- int main()
- {
- char sir[999];
- Citire(sir);
- //cout << sir << "\n";
- cout << NrFold(sir) << "\n";
- //-----3-----
- int s = 0;
- char *p, sep[] = "x=+ ", expr[99];
- cin.getline(expr, 99); //scrii x=15+127
- p = strtok(expr, sep);
- while(p != NULL)
- {
- s += atoi(p);
- p = strtok(NULL, sep);
- }
- cout << "x = " << s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement