首页 > 其他分享 >第二章

第二章

时间:2022-10-25 10:22:31浏览次数:31  
标签:main 第二章 int break printf go include

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define N 5
int main(){
    int number;
    int i;
    srand(time(0));
    for(i=0;i<N;++i){
number=rand()%500+1;//获得1到500之间任意一个数
printf("20228329%04d\n",number);
    }system("pause");

    return 0;
    system("pause");
}//获得随机五个学号

#include<stdio.h>
#include<stdlib.h>
int main(){
printf("guess what's your lucky day,you have three chances\n");
int x=rand()%31+1;

int n;
    
    int i;
    for(i=1;i<4;i++){
        scanf_s("%d",&n);
    if (n!=x)
    {if(n>x)
    printf("too big\n");
    else 
        printf("too small\n");}
    else{printf("YOU are right\n");
    break;}}
    if(i!=3)
        printf("answer is %d",x);
    system("pause");
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main(){
	char n;
	n=getchar();
	switch(n){
	case('g'):printf("go go go");break;
	case('r'):printf("stop");break;
#include<stdio.h>
#include<stdlib.h>
int main(){
double sum,a;
sum=0;
int i,n;

scanf_s("%d%lf",&n,&a);
int k=a;
for(i=1;i<=n;i++){
    sum=sum+i/a;
    a=a*k;}
    printf("%lf",sum);
        system("pause");
        return 0;}

#include<stdio.h>
#include<stdlib.h>
int main(){
int i,h,sum;
for(h=1;h<=9;h++){
for(i=1;i<=h;i++)
{sum=i*h;
printf("%dx%d=%2d ",i,h,sum);}
printf("\n");}
system("pause");
return 0;}

#include<stdio.h>
#include<stdlib.h>
int main(){
    int x,i,h,y;
    scanf_s("%d",&x);
    for(h=x;h>=1;h--){
        for(y=1;y<=5*(x-h);y++){
            printf(" ");}
        for(i=1;i<=(2*h-1);i++)
        {
            printf("  0  ");
        }
        printf("\n");
        
for(y=1;y<=5*(x-h);y++){
            printf(" ");}
for(i=1;i<=(2*h-1);i++){
printf(" <0> ");}
        printf("\n");
for(y=1;y<=5*(x-h);y++){
            printf(" ");}
for(i=1;i<=(2*h-1);i++){
printf(" I I ");}
        printf("\n");}
    system("pause");
    return 0;}

 

	case('y'):printf("wait");break;
	default:printf("wrong");
	}
	system("pause");
	return 0;}

  

标签:main,第二章,int,break,printf,go,include
From: https://www.cnblogs.com/realmanwangzihao/p/16823991.html

相关文章