Submit: 301 Solved: 161
[ Submit ][ Status ][ Web Board ]
Description
The following program converts uppercase letters into lowercase letters and lowercase letters into uppercase letters in a string (the length of the string does not exceed 10). The program segment marked with * is wrong, and the program statement cannot be added or subtracted when the error is corrected. Submit this part of the statement.
Input
Enter a string of characters, including upper and lower case letters, and other legal characters.
Output
Output a string of characters, converting uppercase letters to lowercase and lowercase letters to uppercase.
Sample Input
AB2cd
Sample Output
ab2CD
HINT
Source
Code:
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
char a[10];int n;
cin>>a;
n=strlen(a);
for(int i=0;i<n;i++)
{
if(a[i]>='A'&&a[i]<='Z')
a[i]=a[i]+32;
else if(a[i]>='a'&&a[i]<='z')
a[i]=a[i]-32;
}
cout<<a;
return 0;
}