#include <iostream>
using namespace std
int _tmain(int argc, _TCHAR* argv[])
{
int a
cout<<"请输入数字"<<endl
cin>>a
int b=0
while(a)
{
b=a%10+10*b
a=a/10
}
cout<<b<<endl
system("pause")
return 0
}
// 记得多给点分哦,很难写的。// C
#include <stdio.h>
int strnmerge(char*str,int n,char const*s1,char const*s2){
while(n > 0) {
if(!(*s1) && !(*s2)) break
if(*s1 && n > 0) {
*str++ = *s1++
--n
}
if(*s2 && n > 0) {
*str++ = *s2++
--n
}
}
*str = '\0'
}
int main() {
char s1[] = "aaaa"
char s2[] = "bbbbbbbbb"
char str[100]
strnmerge(str, 10, s1, s2)
printf("s1 = %s\n", s1)
printf("s2 = %s\n", s2)
printf("str = %s\n", str)
return 0
}
// C++
#include <iostream>
using namespace std
int strnmerge(char*str,int n,char const*s1,char const*s2){
while(n > 0) {
if(!(*s1) && !(*s2)) break
if(*s1 && n > 0) {
*str++ = *s1++
--n
}
if(*s2 && n > 0) {
*str++ = *s2++
--n
}
}
*str = '\0'
}
int main() {
char s1[] = "aaaa"
char s2[] = "bbbbbbbbb"
char str[100]
strnmerge(str, 10, s1, s2)
cout << "s1 = " << s1 << endl
cout << "s2 = " << s2 << endl
cout << "str = " << str << endl
return 0
}
#include <stdio.h>void BuddleSort(int array[], int n)
void main()
{
int a[10]
int i
printf("请输入10个数:\n")
for(i=0i<10i++)
scanf("%d",&a[i])
BuddleSort(a,10)
printf("\n排序后:\n")
for(i=0i<10i++)
printf("%d,",a[i])
printf("最大值:%d",a[9])
printf("最小值 : %d",a[0])
}
void BuddleSort(int array[], int n)
{
int i, j
bool flag = true
for (i = 1flag &&i <ni++)
{
flag = false
for (j = 0j <n - ij++)
{
if (array[j] >array[ j + 1])
{
flag = true
int temp = array[j]
array[j] = array[j + 1]
array[j + 1] = temp
}
}
}
}
楼主参考参考~~记得采纳哦~
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)