第十一次作业
1求字符串长度
#include <stdio.h>
main()
{
char str[80];
int i=0;
int length=0;
gets(str);
puts(str);
while(str[i++]!='\0')
length++;
printf("字符串长度为:%d\n",length);
}

2 #include<stdio.h>
main()
{
char str[20];
int i,cnt;
cnt=i=0;
gets (str);
while(str[i]!='\0')
{
if(str[i]>='A'&&str[i]<='Z')
cnt++;
i++;
}
printf("大写字母的个数为:%d\n",cnt);
}

3 #include<stdio.h>
main()
{
char str[20];
int i,j;
j=i=0;
gets (str);
while(str[i]!='\0')
{
if(str[i]>='*')
str[j++]=str[i];
i++;
}
i=0;
while(i<j)
putchar(str[i++]);
}
4#include<stdio.h>
main()
{
char a[20],b[20];
int i,j;
gets(a);
for(i=j=0;a[i]!='\0';i++)
{
b[j++]=a[i];
if((i+1)%3==0)
b[j++]=' ';
}
b[j]='\0';
puts(b);
}
5#include<stdio.h>
main()
{
char str[80];
int i=0;
gets(str);
while (str[i]!='\0')
{
if((i+1)%2==1&&str[i]%2==0)
putchar(str[i]);
i++;
}
}

浙公网安备 33010602011771号