6 条题解

  • 3
    @ 2025-2-25 23:03:05

    so easy

    考点:

    1. for循环
    2. if判断

    上代码,求点赞

    #include<bits/stdc++.h>
    using namespace std;
    int t[15],a,b,maxn=8,ans=0; //t[15]:记录每天的课程总时间;maxn:当前会不高兴的最大时间;ans:不高兴的最大时间对应的天数编号 
    int main(){
    	for(int i=1;i<=7;i++){
    		cin>>a>>b; //输入 
    		t[i]=a+b; //总时间为学校上课时间和妈妈安排上课时间之和 
    	}
    	for(int i=1;i<=7;i++){ //记录最大值与所在位置 
    		if(t[i]>maxn){
    			maxn=t[i];
    			ans=i;
    		}
    	}
    	cout<<ans; //输出 
    	return 0;
    }
    
    
    • 1
      @ 2025-4-5 21:24:08
      //By Wuzke_
      #include<iostream>
      using namespace std;
      int a,b,max_=-1,ans;
      signed main(){
      	for(int i=1;i<=7;i++){
              cin>>a>>b;
              if(max_<a+b){
                  max_=a+b;
                  ans=i;
              }
          }
          if(max_>8) cout<<ans<<endl;
          else cout<<0<<endl;
        	return 0;
      }
      
      • 1
        @ 2024-11-1 18:39:45
        #include<bits/stdc++.h>
        using namespace std;   
        int a,b,s,maxn,i,d;
        int main(){
            for(i=1;i<8;i++){
                cin>>a>>b;   
                s=a+b;  
                if((s>maxn)&&(s>8)){
                    maxn=s;
                    d=i;
                }
              }
            cout<<d; 
            return 0;             
        }
        
        • 0
          @ 2025-3-31 9:31:23

          import java.util.Scanner;

          public class Main2 { public static void main(String[] args) { //定义一个数组,用来存储下周的七天的补课时间 int []arr = new int[7];

              //用for循环接受每天的补课时间,和记录max
              int max = 0;
              Scanner sc = new Scanner(System.in);
              for (int i = 0; i < 7; i++) {
                  int temp1 = sc.nextInt();
                  int temp2 = sc.nextInt();
                  arr[i] = temp1 + temp2;
                  if (arr[i] > max) {
                      max = arr[i];
                  }
              }
              
              //判断会不会不高兴,和哪天最不高兴
              if (max <= 8) {
                  System.out.println(0);
              }
              
              for (int i = 0; i < arr.length; i++) {
                  if (arr[i] == max && arr[i] > 8) {
                      System.out.println(i+1);
                      return;
                  }
              }
          }
          

          }

          • 0
            @ 2024-11-10 10:39:15
            #include<bits/stdc++.h>
            using namespace std;
            int main()
            {
                int n,m,p,q=0;
                for(int i=1;i<=7;i++){
            		cin>>n>>m;
            		if(n+m>8&&m+n>q){
            			p=i;
            			q=m+n;
            		}
            	}
            	cout<<p;
            	return 0;
            }
            
            • 0
              @ 2024-10-29 11:54:04
              #include<bits/stdc++.h>
              using namespace std;
              
              int main() {
                  int time[7][2], anger = 8, day = 0;
                  for (int i = 0; i < 7; i++) {
                      cin >> time[i][0] >> time[i][1];
                      if (time[i][0] + time[i][1] > anger) {
                          anger = time[i][0] + time[i][1];
                          day = i + 1;
                      }
                  }
                  cout << day;
                  return 0;
              }
              
              • 1

              信息

              ID
              5143
              时间
              1000ms
              内存
              128MiB
              难度
              1
              标签
              递交数
              895
              已通过
              394
              上传者