将student a am I转换为 I am a   student(利用空格处理单词)

将student  a  am  I转换为 I  am  a   student

#include <stdio.h>
#include <string.h>

void reverse( char *start,char *end )
{
  char* left = start;
  char* right = end;
  char temp;
  while( left < right )
  {
    temp = *left;
   *left = *right;
   *right = temp;
   left++;
   right--;
 }
}
void check( char *p )
{
 
 while( *p != ‘\0‘)
 {
  char *pst = p;
  while( *p != ‘\0‘ && *p != ‘ ‘ )
  {
   p++;
  }
  reverse( pst,p-1 );
  if(*p!=‘\0‘)
     p++;
 }
}
int main()
{
 char p[30] = "student a am i";
 int len = strlen(p);
 printf("翻转后的字符串是:");
 reverse(p,p+len-1);
 check(p);
 printf("%s\n",p);
 return 0;
}
时间: 2024-08-02 11:02:16

将student a am I转换为 I am a   student(利用空格处理单词)的相关文章

【面试常考】C语言:输入:&quot;student a am i&quot;,输出&quot;i am a student,不能使用库函数

#include<stdio.h> //#include <assert.h> void my_reverse(char *left ,char * right) {  //assert(left);  //assert(right);   用以处理指针函数为空,保证有效  while(left < right)  {   char tmp =  *left;  //借助中间变量实现逆置   *left =  *right;   *right = tmp;   left ++

将中缀表达式转换为后缀表达式,然后利用栈对表达式求值。

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="js.js"></script> </head> <body> 输入中缀表达式空格分隔 例如 2 + 3 <input type=

【c语言】把student a am i 变成 i am a student

// 把student a am i 变成 i am a student //思想:把每个单词翻转,然后再把整体翻转 #include <stdio.h> #include <string.h> //把每次解析出来的单词翻转 void fanw( char *l,char *r ) { char* left = l; char* right = r; char temp; while( left < right ) { temp = *left; *left = *right

字符数组&quot;student a am i&quot;--》&quot;i am a student&quot;

有一个字符数组的内容为:"student a am i",请你将数组的内容改为"i am a student". #include<stdio.h> #include<ctype.h> #include<stdlib.h> int my_strlen(const char *s) { char *eos = (char*)s; while (*eos) { eos++; } return (eos - s); } void *my

sublime text3 将tab转换为2个或4个空格,并显示空格

有很多软件并不能解析tab,而往往有的程序员喜欢使用tab键进行对齐,sublime text可以很好的解决这个问题. 首先打开sublime text,点击preferences->settings即可打开编辑界面,其中左侧preferences.sublime-settings-Default都是设置的一些默认的设置,如果需要修改,则需要将相应的key复制到右侧的preferences.sublime-settings-User 设置tab为4个空格时:"tab_size":

JSON文本转换为JSONArray 转换为 List&lt;Object&gt;

1 package com.beijxing.TestMain; 2 3 import java.io.File; 4 import java.io.IOException; 5 import java.util.ArrayList; 6 import java.util.List; 7 8 import org.apache.commons.io.FileUtils; 9 10 import com.beijxing.entity.Student; 11 12 import net.sf.js

设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。四个表的结构分别如表1-1的表(一)~表(四)所示,数据如表1-2的表(一)~表(四)所示。用SQL语句创建四个表并完成相关题目。

表(一)Student (学生表) -- Create table create table STUDENT ( sno VARCHAR2(3) not null, sname VARCHAR2(8) not null, ssex VARCHAR2(2) not null, sbirthday DATE, class VARCHAR2(5) ) tablespace USERS pctfree 10 initrans 1 maxtrans 255; -- Add comments to the

Spring RPC 入门学习(3)-插入Student对象

Spring RPC 向后台传递对象 1. 新建RPC接口:StudentInterface.java package com.cvicse.ump.rpc.interfaceDefine; import com.cvicse.ump.student.Student; public interface StudentInterface { public Student getStudentById(String id); public Boolean insertStudent(Student

Spring RPC 入门学习(3)-获取Student对象

Spring RPC传递对象. 1. 新建RPC接口:StudentInterface.java package com.cvicse.ump.rpc.interfaceDefine; import com.cvicse.ump.student.Student; public interface StudentInterface { public Student getStudentById(String id); } 2.新建RPC接口的实现类,StudentManager.java pack