07/08/30 14:12:40
>>83の問題1
#include <stdio.h>
#define MAX_NUM 128
int main()
{
char str[MAX_NUM], even[MAX_NUM/2], odd[MAX_NUM/2];
int i, j, k;
printf("文字列入力==>");
scanf("%s", str);
for(i=0, j=0, k=0; str[i]; i++)
{
if(i%2) {odd[j] = str[i];j++;}
else {even[k] = str[i];k++;}
}
odd[j] = even[k] = '\0';
printf("偶数要素:%s\n", even);
printf("奇数要素:%s\n", odd);
return 0;
}