大神帮忙一下 这个程序怎么运行不了呢
#include<stdio.h>#include<string.h>
#define N 10
int main()
{
void input(int[], char name[]);
void sort(int[], char name[]);
void search(int, int[],char name[]);
int num, number, flag = 1, c;
char name;
input(num, name);
sort(num, name);
while (flag == 1)
{
printf("\n input number to look for:");
scanf_s("%d", &number);
search(number, num, name);
printf("continue or not(Y/N)?");
getchar();
c = getchar();
if (c == 'N' || c == 'n')
flag = 0;
}
system("pause");
return 0;
}
void input(int num[], char name)
{
int i;
for (i = 0; i < N; i++)
{
printf("input NO.:");
scanf_s("%d", &num);
printf("input name:");
getchar();
gets_s(name,9);
}
}
void sort(int num[], char name)
{
int i, j, min, temp1;
char temp2;
for (i = 0; i < N - 1; i++)
{
min = i;
for (j = i; j < N;j++)
if (num>num)
min = j;
temp1 = num;
strcpy_s(temp2, name,7);
num = num;
strcpy_s(name, name,7);
num = temp1;
strcpy_s(name, temp2,7);
}
printf("\n result :\n");
for (i = 0; i < N; i++)
printf("\n %5d%10s", num, name);
}
void search(int n, int num[], char name)
{
int top, bott, mid, loca, sign;
top = 0;
bott = N - 1;
loca = 0;
sign = 1;
if ((n<num) || (n>num))
loca = -1;
while ((sign == 1) && (top <= bott))
{
mid = (bott + top) / 2;
if (n == num)
{
loca = mid;
printf("NO.%d,his name is %s.\n", n, name);
sign = -1;
}
else if (n < num)
bott = mid - 1;
else
top = mid + 1;
}
if (sign == 1 || loca == -1)
printf("%d not been found.\n", n);
} 哪位 大神行行好 帮帮忙 谢谢啦 我用的是vs2013一直运行不了 #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 10
int main()
{
void input(int[], char name[]);
void sort(int[], char name[]);
void search(int, int[], char name[]);
int num, number, flag = 1, c;
char name;
input(num, name);
sort(num, name);
while (flag == 1)
{
printf("\n input number to look for:");
scanf_s("%d", &number);
search(number, num, name);
printf("continue or not(Y/N)?");
getchar();
c = getchar();
if (c == 'N' || c == 'n')
flag = 0;
}
system("pause");
return 0;
}
void input(int num[], char name)
{
int i;
for (i = 0; i < N; i++)
{
printf("input NO.:");
scanf_s("%d", &num);
printf("input name:");
getchar();
gets_s(name, 9);
}
}
void sort(int num[], char name)
{
int i, j, min, temp1;
char temp2;
for (i = 0; i < N - 1; i++)
{
min = i;
for (j = i; j < N; j++)
if (num>num)
min = j;
temp1 = num;
strcpy_s(temp2, name);
num = num;
strcpy_s(name, name );
num = temp1;
strcpy_s(name, temp2 );
}
printf("\n result :\n");
for (i = 0; i < N; i++)
printf("\n %5d%10s", num, name);
}
void search(int n, int num[], char name)
{
int top, bott, mid, loca, sign;
top = 0;
bott = N - 1;
loca = 0;
sign = 1;
if ((n<num) || (n>num))
loca = -1;
while ((sign == 1) && (top <= bott))
{
mid = (bott + top) / 2;
if (n == num)
{
loca = mid;
printf("NO.%d,his name is %s.\n", n, name);
sign = -1;
}
else if (n < num)
bott = mid - 1;
else
top = mid + 1;
}
if (sign == 1 || loca == -1)
printf("%d not been found.\n", n);
}
不知道你要实现什么 没有报错了 小人 发表于 2015-12-12 09:22
不知道你要实现什么 没有报错了
你用的是什么编译器啊 strcpy不用 strcpy_s 吗我的怎么 总是通不过啊 小人 发表于 2015-12-12 09:22
不知道你要实现什么 没有报错了
谢谢你啊 我自己搞定啦这个函数调用的问题strcpy_s(name,7, temp2); zerone. 发表于 2015-12-12 13:11
谢谢你啊 我自己搞定啦这个函数调用的问题strcpy_s(name,7, temp2);
vs2013
页:
[1]