1.
#include
#include
#include
char* cat(char* des, char* src)
{
char* p;
assert(des != NULL);
assert(src != NULL);
p = des + strlen(des);
while (*p++ = *src++);
return des;
}
int main()
{
char s1[100] = "Computer";
char s2[100] = "Language";
cat(s1, s2);
printf("%s\n", s1);
return 0;
}
2.
#include
#include
int main()
{
char s[] = "C is a general purpose, procedural, imperative computer \
programming language developed in 1972 by Dennis Ritchie at the \
Bell Telephone Laboratories for use with the Unix operating system.";
int up, low, num, space, dot;
char* p = s;
up = low = num = space = dot = 0;
while (*p)
{
if (isupper(*p))
up++;
else if (islower(*p))
low++;
else if (isdigit(*p))
num++;
else if (' ' == *p)
space++;
else if (',' == *p)
dot++;
p++;
}
printf("大写字母: %d\n", up);
printf("小写字母: %d\n", low);
printf("数字: %d\n", num);
printf("空格: %d\n", space);
printf("逗号: %d\n", dot);
return 0;
}
3.
#include
#include
char* copy(char* des, char* src)
{
char* p = des;
assert(des != NULL);
assert(src != NULL);
while (*p++ = *src++);
return des;
}
int main()
{
char s1[100];
char s2[] = "abcdefg";
copy(s1, s2);
printf("%s\n", s1);
return 0;
}
这几个题楼主就好好自己做吧。它们可是面试常见问题之一哦!
十个公司的面试题中就有九个公司喜欢出这种题目。
第一题
#include
#include
using namespace std;
int main()
{
string s1="Computer",s2="Language";
cout<}
楼主工程大的吧。。。。。