第一次
1.
#include<stdio.h>
#include<math.h>
int main()
{
int i, j;
for (i = 100; i <= 200; i++)
{
for (j = 2; j <= i - 1; j++)
{
if (i%j== 0)
break;
else
printf("%d\n", i);
}
}
return 0;
}
2.
#include<stdio.h>
int main()
{
int i, j;
for (i = 1; i <= 9; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d*%d=%d", i, j, i*j);
}
printf("\n");
}
return 0;
}
3
#include<stdio.h>
int main()
{
int year;
for (year = 1000; year <= 2000; year++)
{
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
printf("%d", year);
}
return 0;
}
第二次
1.
#include<stdio.h>
//#include <stdlib.h>
int main()
{
int a = 3, b = 7;
a = a^b;
b = b^a;
a = a^b;
printf("a=%d b=%d\n", a, b);
system("pause");
return 0;
}
2.
#include<stdio.h>
#include <stdlib.h>
int main()
{
int i ;
int a[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int max = a[0];
for (i = 0; i <= 9; i++)
{
if (a[i] > max)
max = a[i];
}
printf("max=%d\n", max);
system("pause");
return 0;
}
第三次
1.#include<stdio.h>
#include<stdlib.h>
int main()
{
int A[3] = { 1, 2, 3 }, B[3] = { 2, 4, 6 },C[3];
int i;
for (i = 0; i < 3; i++)
{
C[i] = A[i];
A[i] = B[i];
B[i] = C[i];
}
for (i = 0; i < 3; i++)
printf("%d", A[i]);
printf("\n");
for (i = 0; i < 3; i++)
printf("%d", B[i]);
system("pause");
return 0;
}
2.
3.
#include<stdio.h>
#include<stdlib.h>
#include <conio.h>
int main()
{
int x, y, z, t;
scanf("%d%d%d", &x, &y, &z);
if (z > x)
{
t = x; x = z; z = t;
}
if (y > x)
{
t = x; x = y; y = t;
}
if (z > y)
{
t = y; y = z; z = t;
}
printf("%d%d%d", x, y, z);
system("pause");
return 0;
}
4.