#define N 10
void invert(int *s,int i,int j)
{ int t
if(i<j)
{
t=*(s+i)
*(s+i)=*(s+j)
*(s+j)=t
invert(s,i+1,j-1)
}
}
void main()
{ int a[N],i
for(i=0i<Ni++)
scanf("%d",&*(a+i))
invert(a,0,N-1)
for(i=0i<Ni++)
printf("%d ",a[i])
printf("\n")
}
///////////////////////////////////
#include <stdio.h>
#include <string.h>
#define N 80
int fun( char *s)
{
int count=0, i=0
int flag = 0
while(s[i] != '\0') {
if(flag==0 &&s[i]>举野简='a' &&s[i]<='z') {
count ++flag = 1
}
else if (flag ==1 &&s[i] ==' ')
{
flag = 0
}
i++
}
return count
}
void main()
{ char line[N]
int num=0
printf("正裤Enter a string :\n")
gets(line)
num=fun(line)
printf("The number of word is : %d\n\n",num)
//脊基NONO()
}
1#include "薯颂stdio.h"
void find(int *a,int n,int *max,int *min)
{
int i
*max=*min=0
for(i=1i<ni++)
if(a[i]>a[*max])
*max=i
else if(a[i]<a[*min])
*min=i
}
void main( )
{
int a[]={5,8,7,6,2,7,3},max,min
find(a,7,&max,&min)
printf("\n%d, %d\n",max,min)
}
2
#include "洞首stdio.h"
void invert(int *s,int i,int j)
{
int t
if(i<j)
{
t=*(s+i)
*(s+i)=*(s+j)
*(s+j)=t
invert(s,i+1,j-1)
}
}
void main( )
{
int a[10],i
for(i=0i<10i++) scanf("%d",&a[i])
invert(a,0,10-1)
for(i=0i<10i++)
printf("纳手数%d",a[i])
printf("\n")
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)