#include <stdio.h>
int main()
{
int x,y;
x = 10;
y = -3;
printf("x+y=%d\n", x+y );
printf("x-y=%d\n", x-y );
printf("x*y=%d\n", x*y );
printf("x/y=%d\n", x/y );
printf("x%%y=%d\n", x%y );
return 0;
}
int main()
{
int x,y;
x = 10;
y = -3;
printf("x+y=%d\n", x+y );
printf("x-y=%d\n", x-y );
printf("x*y=%d\n", x*y );
printf("x/y=%d\n", x/y );
printf("x%%y=%d\n", x%y );
return 0;
}
#include <stdio.h>
int main()
{
int arrFirst[3] = {4,5,6};
int arrSecond[] = {7,2,9};
int arrThird[3];
arrThird[0]=10;
arrThird[1]=0;
arrThird[2]=12;
printf("%d\n", arrFirst[1]);
printf("%d\n",arrSecond[1]);
printf("%d\n", arrThird[1]);
return 0;
}
输出结果:520
int main()
{
int arrFirst[3] = {4,5,6};
int arrSecond[] = {7,2,9};
int arrThird[3];
arrThird[0]=10;
arrThird[1]=0;
arrThird[2]=12;
printf("%d\n", arrFirst[1]);
printf("%d\n",arrSecond[1]);
printf("%d\n", arrThird[1]);
return 0;
}
输出结果:520
#include <stdio.h>
int main()
{
int arrFirst[3] = {4,5,6};
int arrSecond[] = {7,2,9};
int arrThird[3];
arrThird[0]=10;
arrThird[1]=0;
arrThird[2]=12;
printf("%d\n", arrFirst[1]);
printf("%d\n",arrSecond[1]);
printf("%d\n", arrThird[1]);
return 0;
}
int main()
{
int arrFirst[3] = {4,5,6};
int arrSecond[] = {7,2,9};
int arrThird[3];
arrThird[0]=10;
arrThird[1]=0;
arrThird[2]=12;
printf("%d\n", arrFirst[1]);
printf("%d\n",arrSecond[1]);
printf("%d\n", arrThird[1]);
return 0;
}
#include<stdio.h>
int main()
{
int sum = 0;
int i = 1;
int flag = 1;
do{
i++;
sum+=i*flag;
flag=-flag;
}while(i<=100);
i=1;
printf("sum=%d\n",sum);
return 0;
}
int main()
{
int sum = 0;
int i = 1;
int flag = 1;
do{
i++;
sum+=i*flag;
flag=-flag;
}while(i<=100);
i=1;
printf("sum=%d\n",sum);
return 0;
}
2023-04-09
#include <stdio.h>
int main()
{
int year = 2010; //今年是2014年
//补全一下代码
if((year%4!=0))
{
printf("%s\n","今年是平年");
}
else
{
printf("%s\n","今年是闰年");
}
return 0;
}
int main()
{
int year = 2010; //今年是2014年
//补全一下代码
if((year%4!=0))
{
printf("%s\n","今年是平年");
}
else
{
printf("%s\n","今年是闰年");
}
return 0;
}
2023-04-08
#include <stdio.h>
int main()
{
int i, j, k;
for(i=1; i<5; i++)
{
for(j=3;j>=i;j--)
{
printf(" ");
}
for(k=1;k<2*i;k++)
{
printf("*");
}
printf("\n");
}
return 0;
}
int main()
{
int i, j, k;
for(i=1; i<5; i++)
{
for(j=3;j>=i;j--)
{
printf(" ");
}
for(k=1;k<2*i;k++)
{
printf("*");
}
printf("\n");
}
return 0;
}
2023-04-03