#include
int main() {
char name1[20], name2[20];
int a, b;
printf("enter two name:");
scanf_s("%s", name1, 20);
scanf_s("%s", name2, 20);
a = strlen(name1);
b = strlen(name2);
if (a>b) {
printf("较长的串是%s,较大的串是%s",name1,name2);
}
else {
printf("较长的串是%s,较大的串是%s", name2, name1);
}
}
#include
int main() {
char str1[30], str2[30];
printf("please enter str1:");
gets( str1);
printf("please enter str2:");
gets(str2);
if (strstr(str1, str2) == NULL) {
printf("st2不是str1的子串");
}
else {
printf("str2是str1的子串");
}
return 0;
}
#include
int main() {
char ch[40];
int str;
printf("enter a sentence:");
gets(ch);
str = strlen(ch);
for (int i = 0; i <= str; i++) {
if (ch[i] == ' ') {
printf("\n");
}
else
printf("%c", ch[i]);
}
return 0;
}
#include
#include
int main() {
char ch[40];
int upp=0, low=0,st;
gets(ch);
st = strlen(ch);
for (int i = 0; i<=st;i++) {
if (ch[i]>='A' && ch[i]<='Z') {
upp++;
}
if (ch[i] >= 'a' && ch[i] <= 'z') {
low++;
}
}
printf("upper=%d,lower=%d", upp, low);
return 0;
}
#include
#include
int main()
{
char s[100], n, m = ' ';
int i, len, j;
gets(s);
len = strlen(s);
printf("请输入要查找的字符:\n");
scanf_s("%c", &n);
for (i = j = 0; i <= len; i++)
{
if (s[i] != n || m == 'N' || m == 'n')
{
s[j++] = s[i];
}
else if (m == ' ')
{
printf("找到此字符,要删除吗?");
scanf_s("%c", &m);
if (m == 'N' || m == 'n')
s[j++] = s[i];
}
}
if (m == ' ')printf("未找到此字符\n");
else puts(s);
return 0;
}
#include
int main()
{
int a, b, c,sum;
scanf_s("%d", &a);
scanf_s("%d", &b);
scanf_s("%d", &c);
sum = a + b + c;
printf("Total=%d", sum);
return 0;
}