1、80011程序填空,不要改变与输入输出有关的语句。
输入两个正整数 n 和 m (1 2、e 3、i]);
printf("\n");
}
/*---------*/
void mov(int *x, int n, int m)
{ int i,j,k;
for( i=0;i 4、入n个整数存入数组a中,再输入一个整数x,在数组a中查找x,如果找到则输出相应元素的最小下标,否则输出"Not found"。
要求定义并调用函数search(list, n, x),它的功能是在数组list中查找元素x,若找到则返回相应元素的最小下标,否则返回-1,函数形参 list 的类型是整型指针,形参n和x的类型是int,函数的类型是void。
输入输出示例:括号内为说明
输入
2 (repeat=2)
3 (n=3)
1 2 -6
2 (x=2)
5 (n=5 5、)
1 2 2 5 4
0 (x=0)
输出
index = 1
Not found
#include 6、f("%d", &n);
for(i = 0; i < n; i++)
scanf("%d", &a[i]);
scanf("%d", &x);
/*---------*/
res=search(a,n,x);
if(res != -1)
printf("index = %d\n", res);
else
printf("Not found\n");
}
}
/*---------*/
int search( 7、int list[], int n, int x)
{ int i;
for(i=0; i 8、的顺序排序,函数形参 a 的类型是整型指针,形参n的类型是int,函数的类型是void。
输入输出示例:括号内为说明
输入
3 (repeat=3)
4 (n=4)
5 1 7 6
3 (n=3)
1 2 3
5 (n=5)
5 4 3 2 1
输出
After sorted: 1 5 6 7
After sorted: 1 2 3
After sorted: 1 2 3 4 5
#include 9、int n);
int main(void)
{
int i, n;
int repeat, ri;
int a[10];
scanf("%d", &repeat);
for(ri = 1; ri <= repeat; ri++){
scanf("%d", &n);
for(i = 0; i < n; i++)
scanf("%d", &a[i]);
/*---------*/
sort(a,n);
printf("After sort 10、ed: ");
for(i = 0; i < n; i++)
printf("%d ", a[i]);
printf("\n");
}
}
/*---------*/
void sort(int a[],int n)
{ int i,k,index,temp;
for(i=0;i 11、输入5个字符串,输出其中最大的字符串。
输入输出示例:括号内为说明
输入:
peach
pear
melon
orange
berry
输出:
Max is: pear
#include 12、s", str);
if(strcmp(str,max)>0)
strcpy(max,str);
}
printf("Max is: %s\n", max);
}
80022程序填空,不要改变与输入输出有关的语句。
输入一个正整数 repeat (0 13、 (n=5)
melon peach pear strawberry orange
3 (n=3)
pear berry orange
4 (n=4)
melon peach pear apple
输出:
The longest is: strawberry
The longest is: orange
The longest is: melon
#include 14、 sx[80], longest[80];
int i, n;
int repeat, ri;
scanf("%d", &repeat);
for(ri = 1; ri <= repeat; ri++){
scanf("%d", &n);
scanf("%s", sx);
/*---------*/
strcpy(longest ,sx);
for(i = 1; i < n; i++){
scanf("%s", sx);
if(strlen(sx)>strlen(longest)) 15、
strcpy(longest ,sx);
}
printf("The longest is: %s\n", longest);
}
80023程序填空,不要改变与输入输出有关的语句。
输入一个正整数 repeat (0 16、id。
输入输出示例:括号内为说明
输入
3 (repeat=3)
happy new year (字符串"happy new year")
a (待删除的字符'a')
bee (字符串"bee")
e (待删除的字符'e')
111211 (字符串"111211")
1 (待删除的字符'1')
输出
result: hppy new yer (字符串"happy new year"中的字符'a'都被删除)
r 17、esult: b (字符串"bee"中的字符'e'都被删除)
result: 2 (字符串"111211"中的字符'1'都被删除)
#include 18、eat; ri++){
gets(str);
scanf("%c", &c);
getchar();
/*---------*/
delchar(str,c);
printf("result: ");
puts(str);
}
}
/*---------*/
void delchar(char *str, char c)
{ char *p,*q;
p=str;
while(*p!='\0')
{ if 19、p==c)
{ q=p;
while(*q!='\0')
{ *q=*(q+1); q++;}
*q='\0';
}
if(*p!=c) p++;
}
}
80024程序填空,不要改变与输入输出有关的语句。
输入一个正整数 repeat (0 20、 s。
要求定义并调用函数 strmcpy(s,t,m), 它的功能是将字符串 t 中从第 m 个字符开始的全部字符复制到字符串 s 中,函数形参s和t的类型是字符指针,形参m的类型是int,函数类型是void。
输入输出示例:括号内为说明
输入:
3 (repeat=3)
happy new year
7
happy
1
new
4
输出:
new year (从"happy new year"第7个字符开始组成的新字符串为"new year")
happy (从"happy"第1个字符开始组成的新字符串为 21、"happy")
error input ("new"的长度小于4)
#include 22、t);
scanf("%d", &m);
getchar();
if(strlen(t) < m)
printf("error input");
else{
strmcpy(s,t,m);
/*---------*/
puts(s);
}
}
}
/*---------*/
void strmcpy(char *s, char *t, int m)
{ int i;
for(i=m-1;t[i]!='\ 23、0';i++)
s[i-m+1]=t[i];
s[i-m+1]='\0';
}
80025程序填空,不要改变与输入输出有关的语句。
输入一个正整数 repeat (0 24、
输入输出示例:括号内为说明
输入:
2 (repeat=2)
abcddcba
abcddcb
输出:
YES
NO
#include 25、 != 0)
printf("YES\n");
else
printf("NO\n");
}
}
/*---------*/
int mirror(char *p)
{ int i,length,k;
for(i = 0; p[i]!=’\0’; i++);
length=i;
for(k = 0; k < length/2; k++)
if(p[k]!= p[length-1-k])
return 0;
return 1;
26、}
80026程序填空,不要改变与输入输出有关的语句。
输入一行字符(不超过80个),统计其中的大写字母、小写字母、空格、数字以及其他字符的个数。
输入输出示例:
输入:
bFaE3+8 =1R
输出:
upper: 3 lower: 2 blank: 1 digit: 3 other: 2
#include 27、ower = blank = digit = other = 0;
/*---------*/
for(p=s;*p!=’\0’;p++){
if(*p >='A' && *p <='Z') upper++;
else if(*p >='a' && *p <='z') lowerr++;
else if(*p >='0' && *p <='9') digit++;
else if(*p ==' ') blank++;
else other++;
}
printf( 28、"upper: %d lower: %d blank: %d digit: %d other: %d\n", upper, lower, blank, digit, other);
}
90001程序填空,不要改变与输入输出有关的语句。
输入一个正整数n(3≤n≤10),再输入n个雇员的信息,包括姓名、基本工资、浮动工资和支出,输出每人的姓名和实发工资,实发工资=基本工资+浮动工资-支出。
输入输出示例:括号内为说明
输入:
3 (n=3)
zhao 240 400 75
qian 360 120 50
zhou 560 0 80
输出:
zhao 实发工资: 56 29、5.00
qian 实发工资: 430.00
zhou 实发工资: 480.00
#include 30、 0; i < n; i++)
scanf("%s%lf%lf%lf", s[i].name,&s[i].jbg,&s[i].fdg,&s[i].zc);
for (i = 0; i < n; i++)
printf ("%5s 实发工资:%7.2f\n", s[i].name, s[i].jbg + s[i].fdg - s[i].zc);
}
90002程序填空,不要改变与输入输出有关的语句。
输入一个正整数 repeat (0 31、秒数 n,输出该时间再过 n 秒后的时间值,时间的表示形式为时:分:秒,超过 24 时从 0 时重新开始计时。
输入输出示例:括号内为说明
输入:
3 (repeat=3)
0:0:1
59 (秒数n=59)
11:59:40
30 (秒数n=30)
23:59:40
301 (秒数n=301)
输出:
time: 0:1:0 (0:0:01加上59秒的新时间)
time: 12:0:10 (11:59:40加上30秒的新时间)
time: 0:4:41 (23:59:40加上301秒的新时间)
32、
#include 33、/*---------*/
time. second +=n;
if(time.second>=60){
time. minute+= time.second/60;
time.second= time.second%60;
}
if(time. minute >=60){
time. hour+= time. minute /60;
time. minute = time. minute %60;
}
if(time. hour >= 34、24) time. hour = time. hour %24;
printf("time: %d:%d:%d\n", time.hour, time.minute, time.second);
}
}
90003程序填空,不要改变与输入输出有关的语句。
输入整数n(n<10),再输入n个学生的基本信息,包括序号、姓名和成绩,要求计算并输出他们的平均成绩(保留2位小数)。
输入输出示例:括号内为说明
输入:
3 (n=3)
1 zhang 70
2 wang 80
3 qian 90
输出:
average: 80.00
35、
#include 36、name, &s[i].score);
sum = sum + s[i].score;
}
average=1.0*sum/n;
printf("average: %.2f\n", average);
}
90004程序填空,不要改变与输入输出有关的语句。
输入4个整数a1,b1,a2,b2,分别表示两个复数的实部与虚部,求两个复数之积(a1+b1i)*(a2+b2i),乘积的实部为:a1*a2-b1*b2,虚部为:a1*b2+a2*b1。
输入输出示例:括号内为说明
输入:
3 4 5 6
输出:
(3+4i) * (5+6i) = -9 + 38 37、i
#include 38、x. imag *y. real;
printf("(%d+%di) * (%d+%di) = %d + %di\n", x.real, x.imag, y.real, y.imag, product.real, product.imag);
}
90005程序填空,不要改变与输入输出有关的语句。
编写程序,从键盘输入 n (n<10)本书的名称和定价并存入结构数组中,查找并输出其中定价最高和最低的书的名称和定价。
输入输出示例:括号内为说明
输入:
3 (n=3)
Programming in C
21.5
Programming in VB
18.5
39、Programming in Delphi
25.0
输出:
highest price: 25.0, Programming in Delphi
lowest price: 18.5, Programming in VB
#include 40、
scanf("%d", &n);
getchar();
for(i = 0; i < n; i++){
gets(book[i].name);
scanf("%lf", &x);
getchar();
book[i].price = x;
}
/*---------*/
max_index=min_index =0;
for ( i=1; i 41、ce) min_index = i;
if(book[max_index ].price 42、n<10)个朋友的信息,包括姓名、生日、电话号码,按照年龄从大到小的顺序依次输出通讯录。
输入输出示例:括号内为说明
输入:
3 (n=3)
zhang 19850403 13912345678
wang 19821020 0571-88018448
qian 19840619 13609876543
输出:
wang 19821020 0571-88018448
qian 19840619 13609876543
zhang 19850403 13912345678
#include 43、
int i, index, j, n;
struct address_list{
char name[20];
long birthday;
char phone[20];
}temp, friends[10];
scanf("%d", &n);
for(i = 0; i < n; i++)
scanf("%s%ld%s", friends[i].name, &friends[i].birthday, friends[i].phone);
/*--------- 44、/
for(i= 0;i< n-1;i++)
{ index=i;
for(j=i+1;j 45、me, friends[i].birthday, friends[i].phone);
}
90007程序填空,不要改变与输入输出有关的语句。
输入一个正整数 repeat (0 46、输出:
64 (2006年3月5日是该年的第64天)
65 (2000年3月5日是该年的第65天)
#include 47、for(ri = 1; ri <= repeat; ri++){
scanf("%d%d%d", &date.year, &date.month, &date.day);
/*---------*/
yearday= day_of_year(&date);
printf("%d\n", yearday);
}
}
/*---------*/
int day_of_year(struct date *p)
{ int k, leap;
int tab[2][13]={
{0, 31, 28, 3 48、1, 30,31,30,31,31,30,31, 30,31},
{0, 31, 29, 31, 30,31,30,31,31,30,31, 30,31}
};
leap = (p->year%4==0&&p->year%100!=0) ||p-> year %400==0;
for(k=1; k 49、10),做 repeat 次下列运算:
输入一个时间数值,再输入秒数 n,输出该时间再过 n 秒后的时间值,时间的表示形式为时:分:秒,超过 24 时从 0 时重新开始计时。
要求定义并调用函数 timecal(p, n)实现时间换算,函数形参 p 的类型是结构指针,指向表示时间的结构变量,形参n 的类型是整型,表示秒数,函数类型是 void。
输入输出示例:括号内为说明
输入:
3 (repeat=3)
0:0:1
59 (秒数n=59)
11:59:40
30 (秒数n=30)
23:59:40
301 (秒数n=301)
输出: 50、
time: 0:1:0 (0:0:01加上59秒的新时间)
time: 12:0:10 (11:59:40加上30秒的新时间)
time: 0:4:41 (23:59:40加上301秒的新时间)
#include






