帮忙做下这个题啊!

来源:百度知道 编辑:UC知道 时间:2024/06/17 07:53:47
程序设计题
1.整形数组a有五个元素,其值分别为:1、2、3、4、5,移动该数组的数,使其变成2、3、4、5、1
2. 用户从键盘输入一个字符串(字符中不包含空格),当输入回车时认为输入结束,统计输入字符串中小写英文字母、大写英文字母、数字字符、其他字符的个数

1.整形数组a有五个元素,其值分别为:1、2、3、4、5,移动该数组的数,使其变成2、3、4、5、1

#include <stdio.h>

int main()
{
int i,temp,arr[5]={1,2,3,4,5};

for(i=0;i<5;i++)
printf("%d,",arr[i]);
temp=arr[0];
for(i=0;i<4;i++)
arr[i]=arr[i+1];
arr[4]=temp;
for(i=0;i<5;i++)
printf("%d,",arr[i]);
return 0;
}

2. 用户从键盘输入一个字符串(字符中不包含空格),当输入回车时认为输入结束,统计输入字符串中小写英文字母、大写英文字母、数字字符、其他字符的个数

#include <stdio.h>

int main()
{
int num,lower=0,upper=0,digit=0,other=0;
char ch;

printf("输入一段字符:");//可以有空格。。。
while((ch=getchar())!='\n')
{
if(ch>='a'&&ch<='z')
lower++;
else if(ch>='A'&&ch<='Z')
upper++;
else if(ch>='0'&&ch<='9')
digit++;
else other++;
}
printf("小写字母:%d\n大写字母:%d\n数字:%d\n其