今天算是看到目标了!
今天几位大哥大佬为我指明了方向,在学习上心里有了数,非常感谢!QWTtwentyfive
- 查找字符串k
- 对字符串的字符排序
#include"stdio.h"
int main()
{
while (1)
{
{
char string[100], * p;
int flag = 0;
puts("please input a string:");
gets_s(string);
p = string;
while (*p != '\0')
{
if (*p == 'k')
{
flag = 1;
break;
}
p++;
}
if (flag == 1)
{
printf("We found K");
}
else
printf("NO found");
printf("\n");
}
}
while (1);
return 0;
}
#include"stdio.h"
void swap(char* pa, char* pb)
{
char t;
t = *pa;
*pa = *pb;
*pb = t;
}
int main()
{
char str[80], i, j;
void swap(char* pa, char* pb);
printf("Please input a string:\n");
gets_s(str);
for (i = 0; str[i] != '\0'; i++)
{
for (j = i + 1; str[j]!='\0'; j++)
{
if (str[i] > str[j])
swap(&str[i], &str[j]);
printf("The sorted string is %s\n ", str);
}
}
while (1);
return 0;
}
最近发生的那些自己身上的事情还是社会上的,希望早点过去。