麻烦高手做下这个C语言程序设计题

来源:百度知道 编辑:UC知道 时间:2024/06/16 07:17:39
好久不看书了,都快忘了,明天交作业,急用。
1。整形数组a有5个元素,其值分别为1,2,3,4,5,移动该数组的数,使其变成2,3,4,5,1
2。用户从键盘中输入一个字符串(字符中不包含空格),当输入回车时认为输入结束,统计输入字符串中小写英文字母,大写英文字母,数字字符,其他字符的个数。

先给你救急。这两个题都不难。Good luck!

第二题答案送上:
#include "stdio.h"
#include "conio.h"
main()
{
int upper=0,lower=0,digit=0,other=0,i=0;
char *p,s[80];
printf("\nInput a string:");
while ((s[i]=getchar())!='\n') i++;
p=s;
while(*p!='\n')
{if((*p>='A')&&(*p<='Z'))
upper++;
else if((*p>='a')&&(*p<='z'))
lower++;
else if((*p>='0')&&(*p<='9'))
digit++;
else
other++;
p++;
}
printf("upper case:%2d lower case:%2d ",upper,lower); /*大写,小写*/
printf("digit:%2d other:%2d ",digit,other);/*数字,其他字符*/
getch();
}

第一题

#include <stdio.h>
main(){
int i,temp;
int a[5]={1,2,3,4,5};
temp=a[0];
for(i=0;i<4;i++)
{
a[i]=a[i+1];
}
a[4]=temp;
for(i=0;i