1
//use * output the pattern of letter c
#include<stdio.h>
int main(){
printf("\t\t\t*\n");
printf("\t\t*\n");
printf("\t*\n");
printf("\t*\n");
printf("\t*\n");
printf("\t*\n");
printf("\t\t*\n");
printf("\t\t\t*\n");
}
2
%c是用来输出一个字符,%s是用来输出一个字符串。
3
//output 9*9 formula
#include<stdio.h>
int formula(int i,int j){
printf("%d*%d=%d\n",i,j,i*j);
}
//cannot define a function inside another function
int main(){
int i,j;
for(i=1;i<=9;i++)
for(j=1;j<=9;j++)
{
formula(i,j);
}
}

4
#include<stdio.h>
//output chess board
int main()
{
int i,j;
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)
if((i+j)%2==0)
printf("█");
else printf(" ");
printf("\n");
}
return 0;
}

5rabbit question
i would have like to count how many bunnies are born each month
but the number of rabbits is regular,and it is better for me to use numbers to solve the problem
#include<stdio.h>
int main(){
int i,j=1;
int k;
for(k=1;k<10;k++){
printf("%d\t%d\t",i,j);
i=i+j;
j=i+j;
}
}

522

被折叠的 条评论
为什么被折叠?



