Advertisement
rotti321

Siruri de caractere - trasformari & isalnum

May 11th, 2022
918
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char ch,s[100]={};
  9.   int n;
  10.   cin.getline(s,100);
  11.   n = strlen(s); ///lungimea sirului
  12.   for(int i=0;i<n;i++){
  13.    // if((s[i]>='a' && s[i]<='z')||(s[i]>='A' && s[i]<='Z')) //isalnum
  14.     if(s[i]>='A' && s[i]<='Z'){
  15.       s[i]=s[i]+('a'-'A'); ///transformare 'G'--> 'g'
  16.     }
  17.     else
  18.     if(s[i]>='a' && s[i]<='z'){
  19.       s[i]=s[i]-('a'-'A'); ///transformare 'G'--> 'g'
  20.     }
  21.       cout<<s[i]<<" ";
  22.   }
  23.  
  24. }
  25.  
Advertisement
RAW Paste Data Copied
Advertisement