Advertisement
ittam

ese13

Oct 28th, 2019
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. //Dare un messaggio per dire se in una stringa sono presenti caratteri numerici
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. void ins(string &s);
  7. void lunghezza(string s, int &a);
  8. bool numerici(string s);
  9.  
  10.  main()
  11. {
  12.     string s;
  13.     int a;
  14.     ins(s);
  15.     if(numerici(s))cout<<"non sono presenti numeri"<<endl;
  16.     else    cout<<"sono presenti numeri"<<endl;
  17. }
  18.  
  19.  
  20. void ins(string &s)
  21. {
  22.     cout<<"inserisci una parola ";
  23.     cin>>s;
  24. }
  25.  
  26.  
  27. bool numerici(string s)
  28. {
  29.     int i=0;
  30.     bool t;
  31.     while(s[i])
  32.     {
  33.         t=isalpha(s[i]);
  34.         i++;
  35.     }
  36.     return t;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement