//将数组A中的内容和数组B中的内容进行交换
#include<stdio.h>
#include<stdlib.h>
int main(){
int i;
int a[5],b[5];
int tmp = 0;
printf(“请输入A数组的内容:\n”);
for(i=0; i<5; i++){
scanf("%d",&a[i]);
}
printf(“请输入B数组的内容:\n”);
for(i=0; i<5; i++){
scanf("%d",&b[i]);
}
for(i=0; i<5; i++){
tmp = a[i];
a[i] = b[i];
b[i] = tmp;
}
printf("请输出A数组中的内容:\n");
for(i=0; i<5; i++){
printf("%d\t",a[i]);
}
printf("\n");
printf("请输出B数组中的内容:\n");
for(i=0; i<5; i++){
printf("%d\t",b[i]);
}
printf("\n");
system("pause");
return 0;
}
//计算1/1-1/2+1/3-1/4+1/5…+1/99-1/100的值
int main(){
int i;
double sum = 0.0;
double flag = 1.0;
for(i=1; i<=100; i++){
sum = sum + flag/i;
flag = -flag;
}
printf(“sum = %lf\n”,sum);
system(“pause”);
return 0;
}
//编写程序数一下1到100的所有整数中出现多少次9
int main(){
int i;
int count =0;
for(i=1; i<=100; i++){
if(i == 9 || i%10 == 9 || i/10 == 9){
printf("%4d",i);
count++;
if(count%5 == 0){
printf("\n");
}
}
}
printf("\n");
printf(“count = %d\n”,count);
system(“pause”);
return 0;
}