//求两个数的最小公倍数:
int main()
{
int a = 0,b = 0;
scanf("%d %d", &a, &b);
int min = a > b ? a : b;
while (1)
{
if (min % a == 0 && min % b == 0)
{
printf("%d\n", min);
break;
}
min++;
}
return 0;
}
int main()
{
int a = 0, b = 0;
int i = 1;
scanf("%d %d", &a, &b);
while (1)
{
if (a * i % b == 0)
{
printf("%d", a * i);
break;
}
i++;
}
return 0;
}
//将一句的单词进行倒置标点不倒置
void reverse(char* left, char* right)
{
char tep = 0;
while (left<right)
{
tep = *left;
*left = *right;
*right = tep;
left++;
right--;
}
}//对字符串进行逆置
int main()
{
char arr[100] = { 0 };//三部翻转法
gets_s(arr);
int len=strlen(arr);
reverse(arr, arr + len - 1);//先对整个句子进行翻转
char* start = arr;
while (*start)
{
char* end = start;
while (*end != ' ' && *end != '\0')
{
end++;
}
reverse(start, end - 1);//对句子中的每个单词进行翻转
start = end + 1;
}
printf("%s\n", arr);//输出打印
}
c语言简单的编程练习
最新推荐文章于 2024-08-16 21:54:14 发布