资源描述
// rgh.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include"iostream.h"
#include<string.h>
int salary(char zhicheng[],int x)
{
char a[10]={"jiaoshou"},b[15]={"fujiaoshou"},c[10]={"jiangshi"},d[10]={"zhujiao"};
if(strcmp(zhicheng,a)==0)
return 100*x;
if(strcmp(zhicheng,b)==0)
return 80*x;
if(strcmp(zhicheng,c)==0)
return 60*x;
if(strcmp(zhicheng,d)==0)
return 40*x;
else return 0;
}
void main(){
char zhi[10],name[10];
int y,sum;
cout<<"输入姓名和职称:";
cin>>name>>zhi;
cout<<"输入课时:";
cin>>y;
sum=salary(zhi,y);
cout<<"课酬为:"<<sum<<endl;
}
结果:
输入姓名和职称:lining jiangshi
输入课时:98
课酬为:5880
Press any key to continue
6. P412习题8
源程序或过程:
// rgh.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include"iostream.h"
#include<iomanip.h>
int main(int argc, char* argv[]){
char *s[4]={"*","***","*****","*******"};
for(int i=0;i<4;i++)
{
cout<<setw(i+4)<<s[i]<<endl;}
}
结果:
*
***
*****
*******
Press any key to continue
展开阅读全文