1 条题解

  • 0
    @ 2024-12-24 9:49:24

    C :

    #include<stdio.h>
    void main()
    {
    	int a,b,t;
    	scanf("%d",&b);
    	while(scanf("%d",&a)!=EOF)
    	{
    		if(a<b)
    		{
    			printf("NO");
    			goto L;
    		}
    		else
    		{
    			t=a;a=b;b=t;
    		}
    	}
    	printf("YES");
    L: ;
    }
    

    C++ :

    #include <stdio.h>
    #define maxSize 1000
    
    bool isSorted(int *arr, int n) {
    	int i, j;
    	for (i = 0; i < n; ++i) {
    		for (j = i+1; j < n; ++j) {
    			if (*(arr+i) > *(arr+j)) {
    				return false;
    			}
    		}
    	}
    	return true;
    }
    
    int main() {
    	int num, count = 0;
    	int arr[maxSize];
    	
    	while (scanf("%d", &num) != EOF) {
    		arr[count++] = num;
    	}
    	
    	bool flag = isSorted(arr, count);
    
    	if (flag) {
    		printf("YES\n");
    	} else {
    		printf("NO\n");
    	}
    
    	return 0;
    }
    
    • 1

    信息

    ID
    895
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者