#include <stdio.h>
int main () 
{
	int a,b,c;
    for(a=1;a<=5;a++)
    {
        for(b=1;b<=5-a;b++)
        {
            printf(" ");
        }
        for(c=1;c<=2*a-1;c++)
        {
            printf("*");
        }
        printf("\n");
    }
    	return 0;
}
2943916373(null) - 2019-10-31 0 人
金字塔输出

#include <stdio.h>
int main ()
{
    float x=-1,y;
    int n;
    printf("输入x的值:");
    scanf("%f\n",&x);
    n=x/10;
    switch(n)
    {
        case 1:
        case 2:
            y=3*x-1;
            break;
        case 3:
        case 4:
        case 5:
            y=4*x-2;
            break;
        default:
            y=(x<1)?x:x<10?2*x-1:5*x;
            break;        
    }
    printf("y的值是:%f\n",y);
    
   
	return 0;
}
cthw19377142156(前端大神) - 2019-10-21 0 人
条件混合运算
#include<stdio.h>
int main()
{
    int a;
    while(a!=0)
    {
        printf("menu-----\n");
        printf("sell-----1\n");
        printf("buy-----2\n");
        printf("show----3\n");
        printf("out-----0\n");
        scanf("%d",&a);
        switch(a)
        {
            case 1:
                printf("you are selling to consumer\n");
                break;
            case 2:
                printf("you are buying sometjing\n");
                break;
            case 3:
                printf("checking the store\n");
                break;
            case 0:
                printf("the program is out\n");
                break;
            default:
                printf("You put a wrong selection\n");
                break;    
        }
    }
    
    return 0;
}
cthw19377142156(前端大神) - 2019-10-21 0 人
显示游戏菜单
#include <stdio.h>
int main () {
    int n,just;
    scanf("%d",&n);
    just=n%5;//%5=0
    if(just>3){
        printf("Drying in day %d",n);
    }else if(just==0){
        printf("Drying in day %d",n);
    }else{
        printf("Fishing in day %d",n);
    }
    return 0;
}
cthw19377142156(前端大神) - 2019-10-21 0 人
三天打鱼两天晒网
#include <stdio.h>
#include <stdlib.h>
#define MAXSIZE 50
#define TRUE 1
#define FALSE 0

typedef int Status;

typedef struct 
{
    int data[MAXSIZE];
    int length;
}Sqlist;

Sqlist* initList()
{
    Sqlist *L;
    L = (Sqlist *)malloc(sizeof(Sqlist)); 
    L->length = 0;
    return L;
}

void disposeList(Sqlist* L)
{
    free(L);
}

Status CreateList(Sqlist* L,int a[],int size)
{
    if(size > MAXSIZE) return FALSE;
    int i = 0;
    for(i;i < size;i++)
    {
        L->data[i] = a[i];
    }
    return TRUE;

}


Status getData(Sqlist L,int i,int *e){ 

    if(i <= 0 || L.length == 0 || i > L.length ){
        return FALSE;
    }
    *e = L.data[i-1];
    return TRUE;
}

Status isEmpty(Sqlist *L)
{
	return (L->length == 0);
}


/**
 * [locate description]
 * @param  L [pointer To The Sequence List]
 * @param  e [Target Element to be found]
 * @return   [an Integer, represents The Index Of The Target Element]
 */
int locate(Sqlist *L,int e)
{
	int i = 0;
	while(i < L->length && L->data[i] != e)
	{
		i++;
	}
	if(i == L->length)
		return -1; // flag -1 suggests variable e does Not Exists
	return i+1;
}


Status isrtData(Sqlist *L,int i,int e)
{
    int j;
    if(L->length == MAXSIZE)
        return FALSE; 
    if(i < 1 || i > L->length + 1)
        return FALSE; 
    if(i == L->length + 1){ 
        L->data[i-1] = e;
        L->length ++;
        return TRUE;
    }

    for(j=L->length-1;j>=i-1;j--){
        L->data[j+1] = L->data[j];
    }
    L->data[i-1] = e;
    L->length ++;
    return TRUE;
}


Status delData(Sqlist *L,int i)
{
    int k;
    if(L->length == 0)
        return FALSE; 
    if(i < 1 || i > L->length)
        return FALSE; 
    if(i == L->length){
        L->data[i-1] = 0;
        L->length -= 1;
        return TRUE;
    }

    for(k=i;k<L->length;k++){
        L->data[k-1] = L->data[k];  
    }
    L->length --;
    return TRUE;
}

Status DispList(Sqlist *L)
{ 
    int i; 
    if(L->length == 0)
        return FALSE;
    for(i = 0;i < L->length;i++)
        printf("%d  ",L->data[i]);
    return TRUE;
}

int main()
{
	int size = 10;
	int array[10] = {1,2,4,4,2,5,2,6,2,1};
	Sqlist* L = initList();
	CreateList(L,array,size);
	DispList(L);
	return 0;
}
switchuser(前端大神) - 2019-09-25 0 人
sequence list
#include <stdio.h>
int main()
{
    int number;
 
    // printf() 输出字符串
    printf("输入一个整数: ");  
    printf("helloWorld");
    // scanf() 格式化输入
    scanf("%d", &number);  
    
    // printf() 显示格式化输入
    printf("你输入的整数是: %d", number);
    return 0;
}
1582(前端大神) - 2019-09-20 0 人
@ 12345
没有了
1/7 下一页