C。。。。越来越和谐了啊。。= =
输入一个英文语句(不记标点符号,单词之间只有一个空格),再逆向输出
例如:I am game boy
boy game am I
#include<stdio.h>
#include<string.h>
int f(char,char,int,int);
int main()
{
char a[80]={0},b[80]={0},c[80]={0};
int i,n,m=0;
printf("Input the sentence\n");
gets(a);
for(i=0;i<80;i++)
{
if(a[i]=='\0')
{
n=i-1;
break;
}
}
f(a,b,0,n);
for(i=0;i<80;i++)
c[i]=b[i];
for(i=0;i<80;i++)
{
if(b[i]==' '||b[i]=='\0')
{
f(b,c,m,i-1);
m=i+1;
}
}
printf("%s\n",c);
return 0;
}
int f(char x[],char y[],int p,int q)
{
int t=q;
for(;p<=t;p++,q--)
y[p]=x[q];
return 0;
}
相关文档:
C/C++ optimizing compilers are great--but there *are* a few techniques for hand-tuning your code to run as efficiently as possible on the AMD Athlon64 and Opteron processors, especially when developing DLLs, device drivers, or other performance-bound pieces of code.
Alan Zeichick
Share | ......
1.引言
C++语言的创建初衷是“a better
C”,但是这并不意味着C++中类似C语言的全局变量和函数所采用的编译和连接方式与C语言完全相同。作为一种欲与C兼容的语言,C++保留了一部分过程
式语言的特点(被世人称为“不彻底地面向对象”),因而它可以定义不属于任何类的全局变量和函数。但是,C++ ......
用了三种方法...
#if 0
void StringTokenize(const std::string& strSrc, const std::string& strDelimit, std::vector<std::string>& vecSub)
{
if (strSrc.empty() || strDelimit.empty())
{
throw "tokenize: empty string\n";
......
1、在C文件中调用C++文件中定义的文件
直接的方法是在C++ 文件的头部添加如下代码段:
extern "C"
{
int API(int A);
}
2、C++接口的方法
在C++中调用C的函数,在C头文件中加入如下代码:
#ifdef __cplusplus // 开始
exte ......