【无标题】

CC=gcc
EXE=a.out
OBJS=$(patsubst %.c,%.o,$(wildcard *.c))
CFLAGS=-c -o
 
all:$(EXE)
 
$(EXE):$(OBJS)
	$(CC) $^ -o $@
 
%.o:%.c
	$(CC) $(CFLAGS) $@ $^
 
.PHONY:clean
 
clean:
	@rm $(OBJS) $(EXE)

 

 


#include<stdlib.h>
#include<string.h>
#include<stdio.h>
int word(char *p)
{
	int i=0,count=0;
    while(*(p+i)==' ')
			i++;
	while(*(p+i)!='\0')
	{
		int j=i;
        while(*(p+j)!=' ' && *(p+j)!='\0')
			j++;
		if(*(p+j)==' ')
			count++;
		while(*(p+j)==' ')
			j++;
		i=j;
	}
	return count+1;
}
int main(int argc, const char *argv[])
{
	char str[40]="";
	printf("please enter the str:");
	gets(str);
	int num=word(str);
	printf("%d\n",num);
 
	return 0;

}

 

 

#!/bin/bash
 
read -p "please enter file:" file #提示输入文件名
 
if [  -b ./$file ]     #判断是否是块设备文件
then
    echo block
elif [ -c ./$file ]    #判断是否是字符设备文件
then
    echo character
elif [ -d ./$file ]    #判断是否是目录文件
then
    echo directory
elif [ -f ./$file ]    #判断是否是普通设备文件
then
    echo file
elif [ -L ./$file ]    #判断是否是软链接文件
then
    echo line
elif [ -S ./$file ]    #判断是否是套接字文件
then
    echo socket
elif [ -p ./$file ]    #判断是否是管道文件
then
    echo pipe
else
    echo unexist                 #若文件不存在输出不存在
fi

 


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, const char *argv[])
{
	char str[30]="";
	printf("please enter str:");
	gets(str);
	puts(str);
	//整体逆置
	int i=0,j=strlen(str)-1;
	while(i<j)
	{
		char t=str[i];
		str[i]=str[j];
		str[j]=t;
		i++;
		j--;
	}
	//单词逆置
	i=j=0;
	while(str[i]!='\0')
	{
		while(str[j]!=' ' && str[j]!='\0')
		{
			j++;
		}
		int k=j-1;
		while(i<k)
		{
			char t=str[i];
			str[i]=str[k];
			str[k]=t;
			i++;
			k--;
		}
		while(str[j]==' ')
		{
			j++;
		}
		i=j;
	}
	i=j=0;
	while(str[i]!='\0')
	{
		if(str[i]!=' ')
			printf("%c",str[i]);
		i++;
	}
	puts("");
 
	return 0;
}

 

 

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值