[ create a new paste ] login | about

Link: http://codepad.org/mPK9vwvj    [ raw code | output | fork ]

C++, pasted on Aug 9:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct plog{
	struct plog *next;
	char Name[600];
	int T_Time;
	int C_Charge;
	int Packet;
	int P_Charge;
	int Total;	
}plog;


int CC_Charge(int TalkTime){
	int C_Charge;

	C_Charge = (int)(((double)TalkTime/10)+0.99)*100;

	if(C_Charge>1000){
		return C_Charge-1000;
	}else{
		return 0;
	}
}


void CP_Charge(plog *Data){

	int d=0;
	d = Data->Packet;	

	if((d>=0)&&(d<=5000)){
		Data->P_Charge = 410;
	}else if((d>5000) && (d<=60000)){
		Data->P_Charge = 410+(d-5000)*0.65;
	}else if(d>56500){
		Data->P_Charge = 5000;
	}else{
		printf("ERROR\n");
		Data->P_Charge = 0;
	}
}

int all_Charge(plog *Data){
	int sum_2=0;

	while(1){
		sum_2 += Data->Total;

		Data=Data->next;

		if(Data->next == NULL){
			break;
		}
	}

	return sum_2;
}

int main(){
	int i,OneYear;
	plog Data[12];

	for(i=0;i<12;i++){
		printf("%d月\n",i);
		printf("時間を入力:");
		scanf("%d",&Data[i].T_Time);

		printf("パケットを入力:");
		scanf("%d",&Data[i].Packet);
	}

	OneYear = OneYear_C(&Data);

	all_Charge(&Data);

	return 0;
}

int OneYear_C(plog *Data){
	int i=0,sum=0,d=0;

	for(i=0;i<12;i++){
		d=CC_Charge(Data[i].T_Time);
		CP_Charge(&Data[i]);		
		Data[i].Total += d+(Data[i].P_Charge);
		sum+=Data[i].Total;
	}

	return sum;
}


Output:
1
2
3
4
5
6
cc1plus: warnings being treated as errors
In function 'void CP_Charge(plog*)':
Line 37: warning: converting to 'int' from 'double'
In function 'int main()':
Line 75: error: 'OneYear_C' was not declared in this scope
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: