#include<stdio.h>
main(){
int a,c,d,e
float b=10000
int f
int num=1
printf("\t\t\t CHNIA BANK ATM\nplease input your secret code:\n")
scanf("%d",&a)
if(a==num){
printf(" welcome you to use your count,you have %.2f RMB!\n",b)
printf(" how much money do you want? please input the numbers: ")
scanf("%d",&e)
printf("\n")
c=b-e
printf(" you till have : %d ,please choose exit or choose function ! \n",c)
scanf("%c",&d)
printf("\n")
}
else if(a!=num){
printf("your secret code is wrong,please input the correct secret code!\n")
}
printf("\t\t \tHELLO,WELCOME TO USE ATM\nplease choose you want function\n")
printf("\n\n")
printf("\t\t-----------------------------------\n")
printf("\t\t|\t\t|\t\t |\n")
printf("\t\t| 1. check\t| 2. withdraw money\t |\n")
printf("\t\t|\t\t|\t\t |\n")
printf("\t\t-----------------------------------\n")
printf("\t\t|\t\t|\t\t |\n")
printf("\t\t| 3. transfer account\t| 4. midify secret code|\n")
printf("\t\t|\t\t|\t\t |\n")
printf("\t\t-----------------------------------\n")
printf("\t\t|\t\t\t\t |\n")
printf("\t\t|\t 0. exit \t\t |\n")
printf("\t\t|\t\t\t\t |\n")
printf("\t\t-----------------------------------\n")
printf("please choose function:\n ")
scanf("%d",&f)
switch(f)
{ case 0:printf("exit")break
case 1:printf("check")break
case 2:printf("withdraw money")break
case 3:printf("transfer account")break
case 4:printf("midify secret code")break
default :printf("it's wrong,please choose in 0~4!")
}
getch()
}
#include<stdio.h>#include<malloc.h>
#define N 10
int main(void)
{
int i,j,x,m,flag=1
char ch
m=N
char (*p)[10]=(char (*)[10])calloc(N,10*sizeof(char))
for(i=0i<10i++)
for(j=0j<10j++)
p[i][j]='\0'
printf("输入ID时不超过10位,第一位不能为'*'\n")
i=0
while(1)
{
while(i<m)
{
printf("请输入第%d名的ID:",i+1)
ch=getchar()
for(j=0j<10j++)
{
if(j==0&&ch=='*')
{
flag=0
break
}
if(ch=='\n')
break
p[i][j]=ch
ch=getchar()
}
if(flag==0)
break
i=i+1
}
if(flag==0)
break
m=m+N
p=(char (*)[10])realloc(p,m*10*sizeof(char))
for(x=ix<mx++)
for(j=0j<10j++)
p[x][j]='\0'
}
for(j=0j<ij++)
{
printf("第%d名:",j+1)
printf("%s\n",p[j])
}
free(p)
return 0
}
代码如下:
#include <stdlib.h>#include <stdio.h>
int main()
{
float balance // 余额
float withdraw // 取款
float save // 存款
char choice // 用户选择键
printf("请输入存款余额(包含两位小数):\n")
scanf("%f",&balance)
do{
printf("请选择:D(存款)W(取款)F(结束).\n")
fflush(stdin)
choice = getchar()
switch(choice)
{
case 'D':
case 'd':
scanf("%f",&withdraw)
balance += withdraw
break
case 'W':
case 'w':
scanf("%f",&save)
balance -= save
if(balance <= 0.0)balance = 0.0
break
case 'F':
case 'f':
printf("当前余额为:%.2f\n", balance)
system("pause")
return 0
default:
break
}
}while(true)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)