當前位置:首頁 » 編程軟體 » 編程小陽

編程小陽

發布時間: 2022-05-07 18:30:45

❶ C++編程小明買書問題

出那個錯誤,是你一個項目裡面有兩個源程序,每個程序中都有main函數了。

在項目中刪除掉一個源程序文件,或者注釋掉一個main函數就可以了

❷ c#編程,某商場正在促銷打折,購物滿100減50,輸入購買的商品的原價,編寫方法計算顧客實際的付款

Console.WriteLine("請輸入商品原價:");
decimal pay = Convert.ToDecimal(Console.ReadLine());
if (pay < 100)
{
Console.WriteLine("顧客實際應付款{0}元", pay);
}
else
{
Console.WriteLine("顧客實際應付款{0}元", pay-50);
}
Console.ReadKey();

說明:以上是C#編程,基於.Net平台進行,本人使用的是Visual Studio 2010(語言是C#)

❸ 編程問題

// testConsole.cpp : 定義控制台應用程序的入口點。

//


#include<cstdlib>

#include <string.h>

#include <conio.h>


int s2i(char * str,int *num)

{

int i;

*num = 0;

if (strlen(str) == 0)

{

return -1;

}

for (i = 0;i < strlen(str);i++)

{

if (*(str + i)<'0' || *(str + i) > '9')

{

return -1;

}

*num = (*num) * 10 + (*(str + i)) - '0';

}

return 0;

}

int getInput(char *str,int maxLen)

{

char c;

int counter = 0;

do

{

c = getch();

if (c != 13)

{

*(str + counter) = c;

counter ++;

printf("%c",c);

fflush(stdout);

}


} while (c != 13 && counter < maxLen);

printf(" ");

*(str + counter) = 0;

return 0;

}


int splitStr(char *str)

{

int i,l;

l = strlen(str);

for(i = 0;i < l;i++)

{

if (*(str + i) == ' ')

{

*(str + i) = 0;

}

}

return 0;

}


void _tmain(int argc, _TCHAR* argv[])

{

int T,n,m,tmp,total;

int *L;

int *H;

int counter;

int i,j;

char bufInput[512];

int l;

char c;

scanf("%d",&T);

if(T<=0)

{

return;

}

L = (int *)malloc(sizeof(int) * T);

H = (int *)malloc(sizeof(int)*T);

for(i = 0;i < T;i++)

{

scanf("%d %d",&n,&m);

if(n < 2 || m<1)

{

return;

}

getInput(bufInput,511);

splitStr(bufInput);

counter = 0;

total = 0;

for(j = 0;j < n - 1;j++)

{

if (s2i(bufInput + counter,&tmp)!=0)

{

return;

}

counter += strlen(bufInput + counter) + 1;

total +=tmp;

}

total = (total - 1) / (n-1);

*(H + i) = total;


getInput(bufInput,511);

splitStr(bufInput);

counter = 0;

total = 0;

for(j = 0;j < m;j++)

{

if (s2i(bufInput + counter,&tmp)!=0)

{

return;

}

counter += strlen(bufInput + counter) + 1;

total +=tmp;

}

total = (total + m - 1) / m; //向上取整

*(L + i) = total;

}

for(i = 0;i < T;i++)

{

printf("%d %d ",*(L + i),*(H + i));

}

free(L);

free(H);

system("PAUSE");

return;

}




c語言 編程

#include <stdio.h>
#include <math.h>
main()
{
long int f(int i); // 第n天還有的餅干數
long int a ;
a = f(1);
printf("第一天有餅干數即買的餅干數=%d\n", a);
}

long int f(int i)
{
long int b;
if (i != 10)
b = 2*(f(i+1)+1);
else
b=1;
return b;
}

❺ c語言編程:輸入一個姓名,如果輸入小明,輸出好人,如果輸入其他任何東西,輸出錯誤。

#include<stdio.h>
#include<string.h>

intmain(void)
{
intname[20];
scanf("%s",&name);
if(strcmp(name,"小明")==0)printf("好人");
elseprintf("ERROR");
return0;
}

❻ C語言的編程

#include<stdio.h>
void main()
{
int a,b,i;
for(i=999;i>0;i++)
{
printf("請輸入員工業績\n");
scanf("%d",&a);
if a<=2000
b=a;
else if a<=5000
b=1.08*a;
else if a<=10000
b=1.1*a;
else if a>10000
b=1.12*a;
printf("該員工工資為%d",b)
}
}

❼ C語言編程小明搬水果問題怎麼解

1,設置一個總耗費計數器;
2,從小到大排序;
3,取前倆合並,將合並值累加至總耗費計數器;
4,回到2,直到合並結果只剩一個;
完成

❽ C語言編程

#include<stdio.h>
#include<stdlib.h>
typedefstruct
{
longnumber;
charname[10];
floatscore[3];
floataverage;
intrank;
}DAT;
#defineN(5)
voidfunc(DAT*d,intn);
intmain()
{
DATdata[N];
inti;
for(i=0;i<N;++i)
{
scanf("%ld%s%f%f%f",&data[i].number,data[i].name,&data[i].score[0],&data[i].score[1],&data[i].score[2]);
}
func(data,N);
for(i=0;i<N;++i)
{
printf("%-9ld%-10s%-5.1f%-5.1f%-8.1f%-10.1f%-d ",data[i].number,data[i].name,data[i].score[0],data[i].score[1],data[i].score[2],data[i].average,data[i].rank);
}
return0;
}
intcmp_score(void*a,void*b)
{
return((DAT*)b)->average-((DAT*)a)->average;
}
intcmp_number(void*a,void*b)
{
return((DAT*)a)->number-((DAT*)b)->number;
}
voidfunc(DAT*d,intn)
{
inti;
for(i=0;i<n;++i)
{
d[i].average=(d[i].score[0]+d[i].score[1]+d[i].score[2])/3.0;
}
qsort(d,n,sizeof(DAT),cmp_score);
for(i=0;i<n;++i)
{
d[i].rank=i+1;
}
qsort(d,n,sizeof(DAT),cmp_number);
}

網頁鏈接

❾ 程序編程某年紀共有三3個班,每個班共用五名學生,有2個科目的考試成績,求各班每個學生的平均成績並

*共有?
3 * 5 = 15
共有15名學生。
有兩個科目,即
15 * 2 = 30
每個學生有兩份成績,則總共有30份成績。
平均成績是將總體成績分數加起來除以所有成績數,即
x / 30

❿ 請教一道編程題,無需實際的進行編程操作。謝謝。我想問的是,MATLAB跟C++都能完成這道題編程嗎

可以的,在matlab 的.mat 格式文件存儲每位同學的身高差,再在.m 文件里導入該mat文件,再循環將身高差加上小明的身高就可以得到每個同學的身高了。

c++也是一樣,只需要建立個vector 存儲所有身高差,再循環加上小明的身高就可以得到每個同學的身高

熱點內容
動圖在線壓縮 發布:2025-05-14 03:35:24 瀏覽:131
w7共享無法訪問 發布:2025-05-14 03:35:24 瀏覽:481
為什麼微信會出現賬號密碼錯誤 發布:2025-05-14 03:03:30 瀏覽:692
幻影腳本官網 發布:2025-05-14 03:01:13 瀏覽:826
servlet的webxml怎麼配置 發布:2025-05-14 02:51:46 瀏覽:772
怎麼取消手勢密碼 發布:2025-05-14 02:51:11 瀏覽:639
openvpn搭建vpn伺服器搭建 發布:2025-05-14 02:47:52 瀏覽:998
密碼忘了從哪裡找 發布:2025-05-14 02:39:09 瀏覽:548
我的世界什麼伺服器有前途 發布:2025-05-14 02:30:31 瀏覽:528
java程序反編譯 發布:2025-05-14 02:18:46 瀏覽:458