Viết chương trình chữ hoa và chữ thường sang kẻ nhau
Code:
#include<bits/stdc++.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
char *s = new char[500];
gets(s);
if(*s >= 65 && *s <= 90)
{
for(int i = 0 ; i < strlen(s) ; i++)
{
if(i % 2 == 0)
putchar(toupper(*(s+i)));
if(i % 2 != 0)
putchar(tolower(*(s+i)));
}
}
if(*s >= 97 && *s <= 122)
{
for(int i = 0 ; i < strlen(s) ; i++)
{
if(i % 2 == 0)
putchar(tolower(*(s+i)));
if(i % 2 != 0)
putchar(toupper(*(s+i)));
}
}
return 0;
}