Advertisement
J00ker

..

Dec 10th, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. char a[101];
  6.  
  7. void StSpatii(char a[])
  8. {
  9. for(int i = 0; a[i] != 0; i++)
  10. if(a[i] == ' ')
  11. {
  12. a[i] = 0;
  13. break;
  14. }
  15. }
  16.  
  17. int Cautare(char a[], char ch)
  18. {
  19. for(int i = 0; a[i] != 0; i++)
  20. if(a[i] == ch) return i;
  21. return -1;
  22. }
  23.  
  24. void Inloc(char s[], char c1, char c2)
  25. {
  26. for(int i = 0; a[i] != 0; i++)
  27. if(a[i] == c1) a[i] = c2;
  28. }
  29.  
  30. int SumSir(char s[])
  31. {
  32. int n = 0;
  33. for(int i = 0; a[i] != 0; i++) n += (a[i] - 48);
  34. return n;
  35. }
  36.  
  37. int main()
  38. {
  39. cout << "a: ";
  40. cin.getline(a, 101);
  41.  
  42. /*
  43. cout << a << "." << "\n";
  44. StSpatii(a);
  45. cout << a << "." << "\n";
  46. */
  47.  
  48. /*
  49. char ch;
  50. cout << "ch: ";cin >> ch;
  51. cout << Cautare(a, ch) << "\n";
  52. */
  53.  
  54. /*
  55. char c1, c2;
  56. cout << "c1: ";cin >> c1;
  57. cout << "c2: ";cin >> c2;
  58. Inloc(a, c1, c2);
  59. cout << a << "\n";
  60. */
  61.  
  62. cout << SumSir(a) << "\n";
  63.  
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement