#14723: 請問程式碼哪裡錯誤


fionahung0908 (username)


#include<bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
int a;
char n;
while(cin>>a)
{
for(int i=1;i<=a;i++)
{
cin>>n;
if(n>='A'&&n<='Z')
{
n+=32;
cout<<n;
}
else if(n>='a'&&n<='z')
{
n-=32;
cout<<n;
}
else cout<<n;
}
}
}

#14728: Re:請問程式碼哪裡錯誤


GHot_Taiwan (306-22 洪堂貴)


#include<bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
int a;
char n;
while(cin>>a)
{
for(int i=1;i<=a;i++)
{
cin>>n;
if(n>='A'&&n<='Z')
{
n+=32;
cout<<n;
}
else if(n>='a'&&n<='z')
{
n-=32;
cout<<n;
}
else cout<<n;
}
}
}


沒換行阿~~~~~大大

#14743: Re:請問程式碼哪裡錯誤


fionahung0908 (username)


#include<bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
int a;
char n;
while(cin>>a)
{
for(int i=1;i<=a;i++)
{
cin>>n;
if(n>='A'&&n<='Z')
{
n+=32;
cout<<n;
}
else if(n>='a'&&n<='z')
{
n-=32;
cout<<n;
}
else cout<<n;
}
}
}


沒換行阿~~~~~大大

謝謝!!

#15710: Re:請問程式碼哪裡錯誤


wish.rirf@gmail.com (C++ 與我)


#include<bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {
int a;
char n;
while(cin>>a)
{
for(int i=1;i<=a;i++)
{
cin>>n;
if(n>='A'&&n<='Z')
{
n+=32;
cout<<n;
}
else if(n>='a'&&n<='z')
{
n-=32;
cout<<n;
}
else cout<<n;
}
}
}


沒換行阿~~~~~大大

謝謝!!

C++可用toupper(),tolower()