求解析下面的程序#include "stdafx.h"#include "iostream"#include "stri
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/09/20 14:39:56
求解析下面的程序
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
string enter(string);
string trim(string);
string l_trim(string);
string r_trim(string);
int main()
{
string strEnter;
strEnter = enter("Please enter your name: ");
strEnter = trim(strEnter);
cout
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
string enter(string);
string trim(string);
string l_trim(string);
string r_trim(string);
int main()
{
string strEnter;
strEnter = enter("Please enter your name: ");
strEnter = trim(strEnter);
cout
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
string enter(string);
string trim(string);
string l_trim(string);
string r_trim(string);
int main()
{
string strEnter;
strEnter = enter("Please enter your name: ");
strEnter = trim(strEnter);
cout<<"Hello, "<<strEnter<<"!\n";
return 0;
}
string enter(string hint) //返回值,参数是string类型
{
string s;
cout<<hint;
getline(cin, s); //获取一行,不需要指定大小
return s; //返回s
}
string l_trim(string s)
{
int i = 0, j;
char c[100];
for (i = 0; s[i] != 0 && (s[i] == '\t' || s[i] == ' '); i++);
//当s字符串的某一个字符不等于0,而且 s字符串 等于 \t 或者 s字符串等于空格,条件都满足才成立
for (j = 0; s[i] != 0; j++)
c[j] = s[i++];
//把s字符串单个复制到c里面,结束条件等于0
c[j] = 0;
return c;
}
string r_trim(string s)
{
int i = s.length(); //获取s字符串的长度
char c[100];
for (i--; i > 0 && (s[i] == '\t' || s[i] == ' '); i--);
//递减循环
c[++i] = 0;
for (i--; i >= 0; i--)
c[i] = s[i];
return c;
}
string trim(string s)
{
int i = 0, j, n;
char c[100];
s = l_trim(r_trim(s)); //调用r_trim函数
n = s.length();
while (i <= n)
{
c[i] = s[i] | 32; //转换成其他的数值 ,加入s[i] = a ,a|32 就是a转换成ASCII码十进制值,然后再转换2进制,32也如此,返回值给c的字符
i++;
}
c[--i] = 0;
for (i=1; i < n; i++)
{
if (c[i] == ' ' && c[i + 1] == ' ')
{
for (j = i + 1; j <= n; j++)
c[j] = c[j + 1];
i--;
n--;
}
}
c[0] = c[0] & 223; //转换的意思
for (i = 1; i < n; i++)
if (c[i] == ' ')
c[i + 1] = c[i + 1] & 223;
return c;
}
#include "iostream"
#include "string"
using namespace std;
string enter(string);
string trim(string);
string l_trim(string);
string r_trim(string);
int main()
{
string strEnter;
strEnter = enter("Please enter your name: ");
strEnter = trim(strEnter);
cout<<"Hello, "<<strEnter<<"!\n";
return 0;
}
string enter(string hint) //返回值,参数是string类型
{
string s;
cout<<hint;
getline(cin, s); //获取一行,不需要指定大小
return s; //返回s
}
string l_trim(string s)
{
int i = 0, j;
char c[100];
for (i = 0; s[i] != 0 && (s[i] == '\t' || s[i] == ' '); i++);
//当s字符串的某一个字符不等于0,而且 s字符串 等于 \t 或者 s字符串等于空格,条件都满足才成立
for (j = 0; s[i] != 0; j++)
c[j] = s[i++];
//把s字符串单个复制到c里面,结束条件等于0
c[j] = 0;
return c;
}
string r_trim(string s)
{
int i = s.length(); //获取s字符串的长度
char c[100];
for (i--; i > 0 && (s[i] == '\t' || s[i] == ' '); i--);
//递减循环
c[++i] = 0;
for (i--; i >= 0; i--)
c[i] = s[i];
return c;
}
string trim(string s)
{
int i = 0, j, n;
char c[100];
s = l_trim(r_trim(s)); //调用r_trim函数
n = s.length();
while (i <= n)
{
c[i] = s[i] | 32; //转换成其他的数值 ,加入s[i] = a ,a|32 就是a转换成ASCII码十进制值,然后再转换2进制,32也如此,返回值给c的字符
i++;
}
c[--i] = 0;
for (i=1; i < n; i++)
{
if (c[i] == ' ' && c[i + 1] == ' ')
{
for (j = i + 1; j <= n; j++)
c[j] = c[j + 1];
i--;
n--;
}
}
c[0] = c[0] & 223; //转换的意思
for (i = 1; i < n; i++)
if (c[i] == ' ')
c[i + 1] = c[i + 1] & 223;
return c;
}
求解析下面的程序#include "stdafx.h"#include "iostream"#include "stri
帮忙解析一个语句#include "stdafx.h"#include "stdio.h"#include "time.
C++语言 找错.#include "stdafx.h"#include #include using namespac
关于c语言的,下面这个程序哪错了?#include "stdio.h" #include "s
程序中那个地方错了?#include "stdafx.h"#includeusing namespace std;int
#include
#include 和#include "time.h"的区别
#include <stdio.h> #include <iostream> int main(
#include #include #include #include #include #include
#include #include #include #include int main(){\x05//S:黑桃 H:
#include #include #include
#include #include #include #include #include /* define