untitled_username

Untitled

Sep 26th, 2020
1,235
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<fstream>
  2. #include<cstring>
  3. using namespace std;
  4. ifstream cin("alfanumeric.in");
  5. ofstream cout("alfanumeric.out");
  6. int main(){
  7. int n,sum=0,k=0;char c,s[2000001];
  8. cin>>n;
  9. for(int i=0;i<n;i++){
  10.     cin>>c;
  11.     if(c>='0' && c<='9'){ sum+=(int(c)-48); }
  12.     if(c>='a' && c<='z'){ c=toupper(c);  }
  13.     if((c>='A' && c<='Z') || (c>='a' && c<='z')){ s[k++]=c; }
  14. }
  15. cout<<s<<endl<<sum;
  16. return 0;
  17. }
RAW Paste Data