入门模拟 B1010——一元多项式求导

时间:2019-12-20 10:54:14   收藏:0   阅读:153

2019-12-20

09:38:48

What The Fuck? 只通过一个样例?

技术分享图片

 

scanf("%d",&t)!=EOF这句很重要!

 

#include <bits/stdc++.h>
#include<math.h>
using namespace std;
const int MAX_LEN = 10005;
int main(){
    int temp[MAX_LEN];
    for(int i=0;i<MAX_LEN;++i){
        temp[i] = 0;
    } 
    int t;
    int count = 0;//计数器 
    while(scanf("%d",&t)!=EOF){
        temp[count] = t;
        count++;
    }
    int result[count];
    for(int i =0;i<count;++i){
        result[i] = 0;
    }
    for(int i=0;i<count-1;){
        int temp1 = i;
        int temp2 = i+1;
        result[i]  = temp[temp1] * temp[temp2];
        result[i+1] = temp[temp2]-1;
        i += 2;
    }
    for(int i = 0;i<count-1;++i){
        if(result[i]!=0){
            cout<<result[i]<<" "; 
        }else{
            cout<<result[i];
        }
    }
    system("pause");
    return 0;
} 

原文:https://www.cnblogs.com/JasonPeng1/p/12071549.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!